Cod sursa(job #950236)

Utilizator alexflav23alfl23 alexflav23 Data 16 mai 2013 13:23:28
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 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 b;
    
    for (int i = 0; i < n; i++) {
        input >> b;
        int digit = std :: atoi(&b[b.length() - 1]);
        if (digit == 0) digit = 10;
        output << values[digit - 1] << '\n';
         
    }
    
    input.close();
    output.close();
    
    return 0;
};