#include <cstdio>
#include <climits>
using namespace std;
int main()
{
unsigned int a, b;
while (scanf("%u%u", &a, &b) == 2 && !(a == 0 && b == 0))
{
int carry = 0;
int count = 0;
int temp;
while (a && b)
{
temp = (a % 10) + (b % 10) + carry;
carry = temp / 10;
count += (carry ? 1 : 0);
a /= 10;
b /= 10;
}
if (a && !b)
{
while (a && carry)
{
temp = (a % 10) + carry;
carry = temp / 10;
count += (carry ? 1 : 0);
a /= 10;
}
} else if (!a && b)
{
while (b && carry)
{
temp = (b % 10) + carry;
carry = temp / 10;
count += (carry ? 1 : 0);
b /= 10;
}
}
if (!count)
{
printf("No carry operation./n");
} else if (count == 1)
{
printf("1 carry operation./n");
} else
{
printf("%d carry operations./n", count);
}
}
return 0;
}
uva10035 Primary Arithmetic
最新推荐文章于 2018-02-07 15:26:54 发布