#include<stdio.h>
int main()
{
long long int i,j,k,l,a,b,la,lb,c[100],d[100],s[100],r,h,z;
int count;
for(i=1;;i++)
{
scanf("%lld%lld",&a,&b);
if((a==0)&&(b==0))
break;
for(j=0;a!=0;j++)
{
c[j]=a%10;
a=a/10;
}
la=j;
for(k=0;b!=0;k++)
{
d[k]=b%10;
b=b/10;
}
lb=k;
l=la;
if(l<lb)
l=lb;
count=0;
h=0;
for(r=0;r<l;r++)
{
if(la>r)
c[r]=c[r];
else
c[r]=0;
if(lb>r)
d[r]=d[r];
else
d[r]=0;
z=c[r]+d[r]+h;
s[r]=z%10;
h=z/10;
if(h>0)
count=count+1;
}
if(count==1)
printf("%d carry operation.\n",count);
else
{
if(count>1)
printf("%d carry operations.\n",count);
else
printf("No carry operation.\n");
}
}
return 0;
}
int main()
{
long long int i,j,k,l,a,b,la,lb,c[100],d[100],s[100],r,h,z;
int count;
for(i=1;;i++)
{
scanf("%lld%lld",&a,&b);
if((a==0)&&(b==0))
break;
for(j=0;a!=0;j++)
{
c[j]=a%10;
a=a/10;
}
la=j;
for(k=0;b!=0;k++)
{
d[k]=b%10;
b=b/10;
}
lb=k;
l=la;
if(l<lb)
l=lb;
count=0;
h=0;
for(r=0;r<l;r++)
{
if(la>r)
c[r]=c[r];
else
c[r]=0;
if(lb>r)
d[r]=d[r];
else
d[r]=0;
z=c[r]+d[r]+h;
s[r]=z%10;
h=z/10;
if(h>0)
count=count+1;
}
if(count==1)
printf("%d carry operation.\n",count);
else
{
if(count>1)
printf("%d carry operations.\n",count);
else
printf("No carry operation.\n");
}
}
return 0;
}
No comments:
Post a Comment