#13381: ___C


hcyang (中輟生)


#include <stdio.h>
#include <stdlib.h>
int main() {
int a,b;
while(scanf("%d %d",&a,&b)==2&&(a!=0||b!=0))
{
int c=a+b;
int count=0;int temp4=0;
while(1)
{
int temp=a%10;
int temp2=b%10;
if(temp>temp2)
temp2+=temp4;
else
temp+=temp4;
int temp3=c%10;
if(temp3<=temp2&&temp3<=temp&&temp!=0&&temp2!=0)
{
count++;
temp4=1;
}
else
temp4=0;
a/=10;
b/=10;
c/=10;
if(a==0&&b==0&&c==0)
{
break;
}
}
if(count==1)
printf("1 carry operation.\n");
if(count==0)
printf("No carry operation.\n");
if(count>1)
printf("%d carry operations.\n",count);
}
return 0;
}

#16656: Re:C


freedom501999@gmail.com (帥氣魔方生)


 



#include <stdio.h>
int main(void)
{
	long long int a, b;
	int c, carry, car;
	while(scanf("%lld %lld", &a, &b)&&(a|b))
	{
		carry=car=0;
		while(a>0 || b>0)
		{
			c= a%10 + b%10 + car;
			if(c>=10)
			{
				carry++;
				car=1;
			}
			else
				car=0;
			a/=10;
			b/=10;
		}
		if(carry==0)
			printf("No carry operation.\n");
		else if(carry==1)
			printf("1 carry operation.\n");
		else
			printf("%d carry operations.\n",carry);
	}
	return 0;
}