Cod sursa(job #33954)

Utilizator Omega91Nicodei Eduard Omega91 Data 19 martie 2007 22:18:59
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <fstream>
#include <string.h>
#include <math.h>
using namespace std;
ifstream f1("cifra.in");
ofstream f2("cifra.out");
int conv(string a) 
{
    int aux, i;
    aux=0;
    aux=aux*10+((int)a[0]-48);
    aux=aux*10+((int)a[1]-48);
    return aux;
}

int main()
{
    const short int uc[20]={1,4,7,6,5,6,3,6,9,0,1,6,3,6,5,6,7,4,9,0};
    const short int sume[20]={0,1,5,2,8,3,9,2,8,7,7,8,4,7,3,8,4,1,5,4};
    const short int s=4;
    string n;
    short int smnf, rasp=0;
    int i, t, asdf;
    f1>>t;
    for (asdf=1; asdf<=t; asdf++)
    {
        rasp=0;
        f1>>n;
        n="0"+n;
        smnf=conv(n.assign(n.end()-2, n.end()));
        f2<<smnf/20*s+sume[smnf%20]%10<<endl;
    }
    f1.close();
    f2.close();
    return 0; 
}