Pagini recente » Cod sursa (job #1476828) | Cod sursa (job #381725) | Cod sursa (job #1496006) | Cod sursa (job #2357704) | Cod sursa (job #3184049)
#include <stdio.h>
#include <string.h>
#include <math.h>
int main() {
int t, i, x, s = 0, p, n, j;
char nr[101];
FILE *out = fopen("cifra.out", "w");
FILE *in = fopen("cifra.in", "r");
fscanf(in, "%d", &t);
for (i = 0; i < t; i++) {
s = 0;
fscanf(in, "%s", nr);
n = strlen(nr);
if (n > 1) {
x = ((nr[n - 2] - '0') * 10 + nr[n - 1] - '0');
s = s + 4 * (x / 20);
} else
x = (nr[n - 1] - '0');
for (j = 1; j <= x % 20; j++) {
if (j % 4 == 0)
s = s + (int)pow(j % 10, 4);
else
s = s + (int)pow(j % 10, j % 4);
}
fprintf(out, "%d\n", s % 10);
}
fclose(in);
fclose(out);
return 0;
}