Cod sursa(job #66459)
Utilizator | MciprianM MciprianM | Data | 18 iunie 2007 18:59:11 |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include<fstream>
#include<string>
using namespace std;
char 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];
ifstream f("cifra.in");
f>>N;
f.close();
char m, bit, r, cifra;
int length=strlen(N);
m=N[length-1];
N[length-1]=0;
length--;
bit=N[length-1]&1;
r=N[length-1]>>1;
cifra=4*r+3*bit+x[m][bit];
ofstream g("cifra.out");
g<<(((int)cifra)%10);
g.close();
return 0;
}