Cod sursa(job #394888)
Utilizator | Barbu Mada shinerain | Data | 11 februarie 2010 19:36:53 |
---|---|---|---|
Problema | A+B | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <string.h>
#include <stdio.h>
int v[12],i,j,x,y,s,aux,k;
char a[11],b[11];
int main()
{
freopen ("adunare.in","r",stdin);
freopen("adunare.out","w",stdout);
scanf("%s",&a);
scanf("%s",&b);
k=strlen(a);
j=strlen(b);
i=0;
for (x=k-1,y=j-1;x>=0,y>=0;x--,y--)
{ s=(a[x]-'0')+(b[y]-'0')+aux;
if (s>10)
{ v[i]=s%10;
aux=1;
}
if (s<10)
{ v[i]=s;
aux=0;
}
if (s==10)
{ v[i]=0;
aux=1;
}
i++;
}
for(j=i-1;j>=0;j--)
printf("%d",v[j]);
return 0;
}