Thứ Ba, 3 tháng 5, 2022

TICHDIEM C++

#include <bits/stdc++.h>
using namespace std;

int i,k,s,n,x; int a[10]={4,2,2,1,2,2,3,2,2,1};
void giai()
{
    cin>>x;
    s=0;
    while (x>0)
    {
        k=x%10;
        x=x/10;
        s=s+a[k];
    };
    cout<<s<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    freopen("tichdiem.inp","r",stdin);
    freopen("tichdiem.out","w",stdout);
    cin>>n;
    for (i=1;i<=n;i++)
        giai();
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.