Cod sursa(job #950232)

Utilizator alexflav23alfl23 alexflav23 Data 16 mai 2013 13:10:27
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <fstream>
const int values[] = {1, 5, 2, 8, 3, 9, 2, 8, 7, 7};

int main(int argc, const char * argv[]) {
    
    std :: ifstream input ("cifra.in");
    std :: ofstream output ("cifra.out");
    
    int n;
    
    input >> n;
    
    std :: string *a = new std :: string[n];
    
    for (int i = 0; i < n; i++) {
        input >> a[i];
        int digit = std :: atoi(&a[i][a[i].length() - 1]);
        if (digit == 0) digit = 10;
        output << values[digit -1];
    }
    
    
    delete[] a;
    
    input.close();
    output.close();
    
    return 0;
};