文章
145
粉丝
217
获赞
21
访问
85.3k
#include <stdio.h>
#include <string.h>
int flag;
void Sum(char *s1,char *s2)
{
int n = strlen(s1)-1;
while(n >= 0)
{
if(n == 0)
{
if((s1[n] - '0') + (s2[n] - '0') >= 10)
flag = 1;
}
else if((s1[n] - '0') + (s2[n] - '0') >= 10)
s1[n-1]+=1;
s1[n] = ((s1[n] - '0') + (s2[n] - '0')) % 10 + '0';
n--;
}
}
int main()
{
char s1[1000],s2[1000];
while(scanf("%s",s1) != EOF)
{
scanf("%s",s2);
flag = 0;
Sum(s1,s2);
char *p = s1;
if(flag == 1) printf("1");
while(*p != '\0')
{
printf("%c",*p);
p++;
}
printf("\n");
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发