Cod sursa(job #977531)

Utilizator alexflav23alfl23 alexflav23 Data 26 iulie 2013 02:27:14
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
//
//  cifra.cpp
//  infoarena
//
//  Created by Flavian Alexander on 25/07/2013.
//  Copyright (c) 2013 Flavian Alexander. All rights reserved.
//

#include "cifra.h"
#include <fstream>

int main() {
    
    std :: ifstream fin("cifra.in");
    std :: ofstream fout("cifra.out");
    
    int limit, sum = 0;
    fin >> limit;
    
    int* predefs = new int[101];
    int* results = new int[limit];
    
    for (int i = 0; i <= 100; i++)
    {
        int copy = i % 10;
        sum += (copy * copy) % 10;
        predefs[i] = sum;
    }
    
    for( std::string line; getline( fin, line ); )
    {
        int lastDigit = line.at(line.length());
        int penultimate = line.at(line.length() - 1);
        fout << predefs[penultimate * 10 + lastDigit];
    }
    
    delete [] results;
    
    fin.close();
    fout.close();
    return 0;
};