~cpp #include <iostream> using namespace std; #include <math.h> int numlen(int num) { int turn = 0; while(num >= 10) { num /= 10; turn++; } return (turn+1); } int process(int n1, int n2) { int nums1[11], nums2[11]; int i, max_len, big_num, small_num, num1_len, num2_len, operation = 0; num1_len = numlen(n1); num2_len = numlen(n2); if(num1_len > num2_len) max_len = num1_len; else max_len = num2_len; if(n1 >= n2) { big_num = n1; small_num = n2; } else { big_num = n2; small_num = n1; } for(i = numlen(small_num); i <= max_len+1; i++) { nums2[i] = 0; } nums1[max_len] = 0; nums2[max_len+1] = 0; for(i = 0; i < numlen(big_num); i++) // 나누어 넣기 { nums1[i] = big_num / pow(10, i); nums1[i] = nums1[i] % 10; } for(i = 0; i < numlen(small_num); i++) // 나누어 넣기 { nums2[i] = small_num / pow(10, i); nums2[i] = nums2[i] % 10; } for(i = 0; i < max_len; i++) { if((nums1[i]+nums2[i]) >= 10) { ++operation; nums1[i+1] += 1; } } return operation; } int main() { int n1, n2, operation; while(cin >> n1 >> n2) { if(n1 == 0 && n2 == 0) break; operation = process(n1,n2); //output if(operation == 0) cout << "No carry operation." << endl; else if(operation == 1) cout << "1 carry operation." << endl; else cout << operation << " carry operations." << endl; } return 0; }