Pagini recente » Cod sursa (job #362507) | Cod sursa (job #2048599) | Cod sursa (job #3249198) | Monitorul de evaluare | Cod sursa (job #972236)
Cod sursa(job #972236)
#include <fstream>
#include <string.h>
using namespace std;
int i, j, k, n, out;
char t[101], u[2];
int st[100];
int pow100(int p){
int p10 = p % 10;
int pp = 1;
for (i = 0; i < p; i ++){
pp *= p10;
pp %= 10;
}
return pp;
}
void compute100(){
st[1] = 1;
for(i = 2; i <= 100; i++){
st[i] = st[i-1] + pow100 (i);
st[i] %= 10;
}
}
void read(){
compute100();
int l, nr;
ifstream fi("cifra.in");
ofstream fo("cifra.out");
fi >> n;
for(i = 0; i < n; i ++){
fi >> t;
l = strlen(t);
nr = 0;
if(l > 1){
nr = (t[l - 2] - '0') * 10 + (t[l - 1] - '0');
} else if (strlen(t) == 1) {
nr = t[l - 1] - '0';
}
fo << st[nr] << endl;
}
fi.close();
fo.close();
}
int main(void){
read();
return 0;
}