Cod sursa(job #9872)
Utilizator | Data | 27 ianuarie 2007 18:42:30 | |
---|---|---|---|
Problema | A+B | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.31 kb |
#include<fstream.h>
void main()
{long int s,t,a,b,ca,cb,c,p=1;
ifstream f("adunare.in");
ofstream g("adunare.out");
f>>a; f>>b; s=0; t=0;
while (a!=0||b!=0)
{ca=a%10;
cb=b%10;
c=(ca+cb+t)%10;
t=(ca+cb+t)/10;
s=s+p*c;
p=p*10;
a=a/10;
b=b/10;}
if (t==1) s=s+p*t;
else g<<s;
f.close();
g.close();}