Pagini recente » Cod sursa (job #2218948) | Cod sursa (job #2980329) | Cod sursa (job #1178964) | Profil UCV_Nicola_Radulescu_Vladutu | Cod sursa (job #54771)
Cod sursa(job #54771)
#include "fstream.h"
int main()
{
ifstream in("cifra.in");
ofstream out("cifra.out");
unsigned int t, c;
unsigned long n;
in>>t;
while(t)
{
in>>n;
c=0;
while(n)
{
switch(n%10)
{
case 1: c+=1;
break;
case 2: c+=4;
break;
case 3: c+=7;
break;
case 4: c+=6;
break;
case 5: c+=5;
break;
case 6: c+=6;
break;
case 7: c+=3;
break;
case 8: c+=6;
break;
case 9: c+=9;
break;
case 0: c+=0;
break;
}
n--;
}
out<<c%10;
if(t!=1) out<<"\n";
t--;
}
in.close();
out.close();
return 0;
}