Pagini recente » Cod sursa (job #2906073) | Cod sursa (job #661890) | Cod sursa (job #1754479) | Cod sursa (job #3288420) | Cod sursa (job #792624)
Cod sursa(job #792624)
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin ("cifra.in");
ofstream fout ("cifra.out");
int a[100];
int ucif;
int n;
int number;
int s;
int x;
char citeste [101];
int main ()
{
fin >> n;
fin.ignore(1);
for (int i = 1 ; i < 100 ; ++i)
{
a[i] = i % 10;
for (int j = 1; j < ( (i - 1) % 4) + 1; ++j)
{
a[i] = (a[i] * (i % 10)) % 10;
}
fout << a[i] << ' ';
}
fout << "\n\n";
for (int i = 0; i < n; ++i)
{
s = 0;
fin.getline (citeste, 101);
x = strlen (citeste) - 1;
if (x > 0)
{
number = (citeste [x - 1] - '0') * 10 + (citeste [x] - '0');
fout << "Case 1"<< '\n';
}
else
number = citeste [x] - '0';
fout << number << ' ';
for (int j = 0; j <= number; ++j)
s = (s + a [j]) % 10;
fout << s << '\n';
}
fin.close ();
fout.close ();
return 0;
}