UVa Problem 10035 일차 산술 (초등학생 산술)

1185 단어 cDate
// Primary Arithmetic (     )
// PC/UVa IDs: 110501/10035, Popularity: A, Success rate: average Level: 1
// Verdict: Accepted
// Submission Date: 2011-05-27
// UVa Run Time: 0.068s
//
//     (C)2011,  。metaphysis # yeah dot net
//
//         ,         ,       。          。
	
#include <iostream>
	
using namespace std;
	
int main(int ac, char *av[])
{
	int first, second;
	
	while (cin >> first >> second, first || second)
	{
		int carry = 0;
		int counter = 0;
		while (first && second)
		{
			carry = (((first % 10 + second % 10 + carry) > 9) ? 1 : 0);
			counter += carry;
			first /= 10;
			second /= 10;
		}
		
		while (first)
		{
			carry = ((first % 10 + carry > 9) ? 1 : 0);
			counter += carry;
			first /= 10;
		}
		
		while (second)
		{
			carry = ((second % 10 + carry > 9) ? 1 : 0);
			counter += carry;
			second /= 10;		
		}
		
		if (counter > 1)
			cout << counter << " carry operations." << endl;
		else if (counter == 1)
			cout << "1 carry operation." << endl;
		else
			cout << "No carry operation." << endl;
	}
	
	return 0;
}

좋은 웹페이지 즐겨찾기