Cod sursa(job #1221797)

Utilizator patrick_vladPatrick Vlad patrick_vlad Data 21 august 2014 14:47:10
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.85 kb
#include <math.h>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#define MAX 1500000
#define zeci (now / 10) % 10
#define unit now % 10
#define m7 (7 * ((now / 10) % 10))
using namespace std;
    ifstream f1 ("cifra.in");
    ofstream f2 ("cifra.out");
    /*int u2[4] = {6, 2, 4, 8};
    int u3[4] = {1, 3, 9, 7};
    int u4[2] = {6, 4};
    int u7[4] = {1, 7, 9, 3};
    int u8[4] = {6, 8, 4, 2};
    int u9[2] = {1, 9};*/
    int uI[10] = {0, 1, 5, 2, 8, 3, 9, 2, 8, 7};
    int uII[10] = {0, 1, 7, 0, 6, 1, 7, 4, 8, 7};
int main(){
    int t, i;
    char n[100];
    int sum;
    f1>>t;

    for(i = 0; i < t; i++){
        f1>>n;
        int now = atoi(n);
        if(zeci % 2 == 0){
            f2<<(uI[unit] + m7) % 10<<"\n";
        } else {
            f2<<(uII[unit] + m7) % 10<<"\n";
        }
    }
    return 0;
}