求问一道C语言题

2024-12-31 16:06:02
推荐回答(1个)
回答1:

我写的代码,亲测可行,不晓得满足你的要求不:
#include
#include
int main()
{
int a,b,i,count,len1,len2,len,c,d,k;
char buf1[1000],buf2[1000];
while(scanf("%d %d",&a,&b)!=EOF)
{
sprintf(buf1,"%d",a);
sprintf(buf2,"%d",b);
len1=strlen(buf1);
len2=strlen(buf2);
len=(len1>=len2)?len1:len2;
k=0;
count=0;
for(i=0;i {

c=buf1[i]-'0';
d=buf2[i]-'0';
if(c+d+k>9)
{
count++;
k=1;
}
else
{
k=0;
}
}
printf("%d\n",count);
}
return 0;
}