Cod sursa(job #1116813)
| Utilizator | Data | 22 februarie 2014 20:33:47 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
int main() {
ifstream input;
ofstream output;
input.open("cifra.in");
output.open("cifra.out");
if (input.is_open()) {
int n, a, c, i;
input >> n;
for (i = 1; i <= n; i++) {
input >> a;
c = 0;
for (int j = 1; j <= a; j++) {
c += (int)pow(j, j) % 10;
c %= 10;
}
output << c << endl;
}
}
else {
cout << "Unable to open file";
}
input.close();
output.close();
return 0;
}