Cod sursa(job #1741750)
| Utilizator | Data | 14 august 2016 23:20:36 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <cstdio>
#include <cstring>
using namespace std;
const int MAX_CF = 100;
int sp[] = {0, 1 ,5 ,2 ,8 ,3 ,9 ,2 ,8, 7};
char s[MAX_CF + 5];
int main(){
freopen("cifra.in", "r", stdin);
freopen("cifra.out", "w", stdout);
int t, n, i, last;
scanf("%d ", &t);
for (i = 1; i <= t; i ++){
gets(s);
n = strlen(s);
last = sp[(s[n - 1] - '0')];
if (n > 1)
last += (s[n - 2] - '0') * 7;
printf("%d\n", last % 10);
}
return 0;
}
