Pagini recente » Cod sursa (job #1256365) | Cod sursa (job #1713595)
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int ult(unsigned n)
{
unsigned s=0,i;
for(i=1;i<=n;i++)
{
if(i%4==0)
s+=i*i*i*i;
else if(i%4==1)
s+=i;
else if(i%4==2)
s+=i*i;
else if(i%4==3)
s+=i*i*i;
}
return s%10;
}
int main()
{
unsigned T,i;
char txt[200];
f>>T;
f.getline(txt,200);
for( i=0; i<strlen(txt); i++)
{
if(txt[i]>='0' && txt[i]<='9')
{
g<<ult(txt[i]-'0')<<"\n";
}
}
}