Cod sursa(job #66465)
Utilizator | MciprianM MciprianM | Data | 18 iunie 2007 19:15:56 |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.54 kb |
#include<fstream>
#include<string>
using namespace std;
int x[][2]={
{0,0},{1,1},{5,7},{8,4},{4,0},{9,5},{5,1},{8,8},{4,2},{3,1}
};
int main(){
char N[105];
int T,i;
ofstream g("cifra.out");
ifstream f("cifra.in");
f>>T;
for(i=0;i<T;i++){
f>>N;
int m, bit, r, cifra;
int length=strlen(N);
m=(int)N[length-1];
N[length-1]=0;
length--;
bit=(int)N[length-1];
bit=bit&1;
r=(int)N[length-1];
r=r>>1;
cifra=4*r+3*bit+x[m][bit];
g<<(cifra%10);
}
g.close();
f.close();
return 0;
}