Pagini recente » Cod sursa (job #57785) | Cod sursa (job #2143343) | Cod sursa (job #1084429) | Cod sursa (job #2964966) | Cod sursa (job #1599348)
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main() {
int t,len,rest,cat,ult_cif,aux;
char n[100];
int ult[20] = {0,1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 5, 4};
FILE *pFile,*oFile;
pFile = fopen ( "cifra.in" , "r" );
oFile = fopen ( "cifra.out" , "w" );
fscanf(pFile, "%d", &t);
fgets(n,10,pFile);
for(int i=0; i<t; i++) {
fgets(n, 100, pFile);
len = strlen(n)-1;
if( len == 1) {
aux = n[0]-'0';
ult_cif = ult[aux];
} else {
rest = 10*(n[0]-'0') + n[1]-'0';
cat = rest/20;
rest = rest%20;
for(int j=2; j<len; j++) {
rest = rest*10+n[j]-'0';
cat = rest/20;
rest = rest%20;
}
ult_cif = cat*4+ult[rest];
ult_cif %= 10;
}
ult_cif += '0';
fprintf(oFile, "%c\n" , (char)ult_cif);
}
fclose(pFile);
fclose(oFile);
int s=0,p,test =1000;
for(int i=1;i<=test;i++) {
p=1;
for(int j=1;j<=i;j++) {
aux = i%10;
p *= aux;
p = p%10;
}
s = s+p;
}
cout<<s%10<<'\n';
return 0;
}