文章
36
粉丝
0
获赞
5
访问
22.0k
封装成函数更简洁一点
#include <stdio.h>
#include <math.h>
int main(){
int n1,t1,t2,n2;
while(scanf("%d %d",&n1,&n2)!=EOF){
int sum1=0,sum2=0,len1=0,len2=0;
t1 = n1;
t2 = n2;
while(t1>0){
t1 /= 10;
len1++;
}
while(n1>0){
sum1 = sum1 + n1%10*pow(10, len1-1);
n1 /= 10;
len1--;
}
while(t2>0){
t2 /= 10;
len2++;
}
while(n2>0){
sum2 = sum2 + n2%10*pow(10, len2-1);
n2 /= 10;
len2--;
}
printf("%d\n",sum1+sum2);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发