Cod sursa(job #1713595)

Utilizator DDragonXTruta Dragos Sebastian DDragonX Data 6 iunie 2016 00:11:02
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#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";
            }
    }

}