Cod sursa(job #1321638)

Utilizator predatorGigi Valoare predator Data 19 ianuarie 2015 13:54:07
Problema A+B Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <fstream>
using namespace std;
ifstream fin("adunare.in");
ofstream fout("adunare.out");
int x,y,a[101],b[101],t,c[101],i,j;
int main()
{
    fin>>x>>y;
    while(x!=0)
    { i++;
        a[i]=x%10;
        x=x/10;
    }
    a[0]=i;
    while(y!=0)
    { j++;
        b[j]=y%10;
        y=y/10;
    }
    b[0]=j;
    for(i=1;i<=a[0]||i<=b[0]||t!=0;i++)
    { c[i]=(t+a[i]+b[i])%10;
        t=(t+a[i]+b[i])/10;
    }
    c[0]=i-1;
    for(i=c[0];i>=1;i--)
        fout<<c[i];
    return 0;
}