Pagini recente » Cod sursa (job #1842719) | Cod sursa (job #1036810) | Cod sursa (job #2423563) | Cod sursa (job #1389275) | Cod sursa (job #1661477)
#include <fstream>
#include <cstring>
using namespace std;
int main()
{
ifstream f("cifra.in");
ofstream g("cifra.out");
int t,i,suma;
char pc,rest,x[10000];
f>>t;
f.getline(x,10000,'\n');
for(i=1;i<=t;i++)
{
f.getline(x,10000,'\n');
/*rest='0';
pc='0';
g<<x<<" ";
while(x>='0'&&x<='9')
{
pc=rest;
rest=x;
f>>x;
}*/
if(strlen(x)==1)
{pc='0';
rest=x[0];}
else
{
pc=x[strlen(x)-2];
rest=x[strlen(x)-1];
}
if(rest=='2')
rest='5';
else
if(rest=='3')
rest='2';
else
if(rest=='4')
rest='8';
else
if(rest=='5')
rest='3';
else
if(rest=='6')
rest='9';
else
if(rest=='7')
rest='2';
else
if(rest=='9')
rest='7';
suma=(pc-'0')*7+(rest-'0');
suma=suma%10;
g<<suma<<endl;
}
return 0;
}