Pagini recente » Cod sursa (job #91239) | Cod sursa (job #1315316) | Cod sursa (job #2653247) | Cod sursa (job #282957) | Cod sursa (job #1828398)
#include<iostream>
#include <algorithm>
#include <fstream>
#include <cstring>
using namespace std;
int U(int b)
{
b=b%10;
if (b==0) return 0;
else if (b==1) return 1;
else if (b==2) return 4;
else if (b==3) return 7;
else if (b==4) return 6;
else if (b==5) return 5;
else if (b==6) return 6;
else if (b==7) return 3;
else if (b==8) return 6;
else if (b==9) return 9;
}
int main ()
{
ifstream f("cifra.in");
ofstream g("cifra.out");
int n,s=0;
int t;
f>>t;
int i,j;
for (i=1;i<=t;i++)
{
f>>n;
s=0;
for (j=1;j<=n;j++)
{
s=s+U(j);
}
s=s%10;
g<<s<<'\n';
}
return 0;
}