Cod sursa(job #372253)

Utilizator andreiosxpantherHalalai Tudor Andrei andreiosxpanther Data 9 decembrie 2009 09:04:33
Problema Cifra Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <cstdio>
int seven[10] = {0, 7, 4, 1, 8, 5, 2, 9, 6, 3};
int digit[2][10] = {{0, 1, 5, 2, 8, 3, 9, 2, 8, 7}, // 0, 1, 4, 7, 6, 5, 6, 3, 6, 9
{0, 1, 7, 0, 6, 1, 7, 4, 8, 7}  // 0, 1, 6, 3, 6, 5, 6, 7, 4, 9
};
int main() {
int ntests, a, b, c;
FILE *fin, *fout;
fin  = fopen("cifra.in",  "r");
fout = fopen("cifra.out", "w");
fscanf(fin, "%d\n", &ntests);
while(ntests-- > 0) {
for(a = b = '0'; (c = getc(fin)) != EOF && c != '\n'; a = b, b = c);
fprintf(fout, "%d\n", (seven[a - '0'] + digit[a & 1][b - '0']) % 10);
}
return 0;
}