#include <iostream>
#include<math.h>
using namespace std;
int main()
{ //579 1110 717
int n,m;//123 456 555 555 123 594
while (true)
{
cin >> n >> m;
if (n == 0 && m == 0)
{
break;
}
int carry = 0;
int n_1,m_1;
while (n != 0 && m != 0)
{
n_1 = n % 10;
m_1 = m % 10;
n /= 10;
m /= 10;
if ((n_1 + m_1) >= 10)
{
carry += 1;
n += 1;
}
}
if (carry == 0)
{
cout << "No carry operation." << endl;
}
else if (carry == 1)
{
cout << carry << " carry operation." << endl;
}
else
{
cout << carry << " carry operations." << endl;
}
}
return 0;
}
#include
#include
using namespace std;
int main()
{ //579 1110 717
int n,m;//123 456 555 555 123 594
while (true)
{
cin >> n >> m;
if (n == 0 && m == 0)
{
break;
}
int carry = 0;
int n_1,m_1;
while (n != 0 && m != 0)
{
n_1 = n % 10;
m_1 = m % 10;
n /= 10;
m /= 10;
if ((n_1 + m_1) >= 10)
{
carry += 1;
n += 1;
}
}
if (carry == 0)
{
cout << "No carry operation." << endl;
}
else if (carry == 1)
{
cout << carry << " carry operation." << endl;
}
else
{
cout << carry << " carry operations." << endl;
}
}
return 0;
}
955 45 答案是錯的 可以再思考查一下