Pagini recente » Cod sursa (job #1359673) | Cod sursa (job #3137009) | Cod sursa (job #1805670) | Cod sursa (job #1778719) | Cod sursa (job #8031)
Cod sursa(job #8031)
#include <fstream.h>
#include <stdio.h>
#include <iostream.h>
int mat[4][10];
int main()
{int uc,r,i,T,j;
mat[0][0]=0;mat[0][1]=1;mat[0][2]=6;mat[0][3]=0;mat[0][4]=6;
mat[0][5]=5;mat[0][6]=6;mat[0][7]=0;mat[0][8]=6;mat[0][9]=9;
mat[1][0]=0;mat[1][1]=1;mat[1][2]=0;mat[1][3]=3;mat[1][4]=6;
mat[1][5]=5;mat[1][6]=6;mat[1][7]=7;mat[1][8]=0;mat[1][9]=9;
mat[2][0]=0;mat[2][1]=1;mat[2][2]=4;mat[2][3]=0;mat[2][4]=6;
mat[2][5]=5;mat[2][6]=6;mat[2][7]=0;mat[2][8]=4;mat[2][9]=9;
mat[3][0]=0;mat[3][1]=1;mat[3][2]=0;mat[3][3]=7;mat[3][4]=6;
mat[3][5]=5;mat[3][6]=6;mat[3][7]=3;mat[3][8]=0;mat[3][9]=9;
long n,k;
ifstream f;
f.open("cifra.in");
ofstream g;
g.open("cifra.out");
f>>T;
for (i=1;i<=T;i++)
{
f>>n;
uc=0;
k= n / 10;r= n % 10;
if ((k%2)==1) uc=5;
for (j=1;j<=r;j++)
uc=uc+mat[j%4][j];
uc=uc%10;
g<<uc<<endl;
}
f.close();
g.close();
return 0;
}