Cod sursa(job #319173)
| Utilizator | Data | 30 mai 2009 19:02:50 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
freopen("cifra.in", "r", stdin);
freopen("cifra.out", "w", stdout);
int T, n, r;
int v[] = {0, 1, 5, 2, 8, 3, 9, 2, 9, 8};
char s[101];
scanf("%d", &T);
while(T--){
scanf("%s", s);
n = strlen( s );
r = (n > 2 ? s[n-2] - '0' * 7 : 0) + v[s[n-1] - '0'];
printf("%d\n", r%10);
}
fclose(stdout);
return 0;
}