Pagini recente » Cod sursa (job #277433) | Cod sursa (job #1102430) | Cod sursa (job #350804) | Cod sursa (job #377198) | Cod sursa (job #1480685)
/* Author: Raul Vasile
* Mail: [email protected]
*/
#include <stdio.h>
int main(int argc, char* argv[]) {
// Declarare variable
int length, i;
char c;
int c1 = 0, c2 = 0;
int result[21] = {0, 1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 5, 4, 4};
// Declarare fisiere
FILE *input, *output;
// Deschidere fisiere
input = fopen("cifra.in", "r");
output = fopen("cifra.out", "w");
// Verificare fisiere
if (input == NULL || output == NULL) {
printf("Error opening files");
return 0;
} else {
fscanf(input, "%d", &length);
fscanf(input, "%c", &c);
for (i = 0; i < length; i++) {
int done = 0;
while (done == 0) {
fscanf(input, "%c", &c);
if (c == '\0' || c == '\n') {
done = 1;
} else {
c2 = c1;
c1 = c - 48;
}
}
fprintf(output, "%d\n", result[c2 * 10 + c1]);
c1 = 0;
c2 = 0;
}
}
return 0;
}