Cod sursa(job #895048)

Utilizator florin_ghGheorghe Florin Ionut florin_gh Data 27 februarie 2013 09:31:37
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <fstream>

using namespace std;

int fct[10];
int main()
{
    ifstream read("fact.in");
    ofstream write("fact.out");
    int P, i, s;
    read>>P;
    read.close();
    for(i=0; P; i++)
    {
        fct[i]=(P%10)*5;
        P/=10;
    }
    s=i;
    for(i=0; i<s-1; i++)
        if(fct[i]>=10)
        {
            fct[i+1]+=fct[i]/10;
            fct[i]=fct[i]%10;
        }
    for(i=s-1; i>=0; i--)
        write<<fct[i];
    write<<"\n";
    write.close();
    return 0;
}