#include using namespace std; void output(int& n1, int& n2) { int count = 0; bool flag = false; while(n1 n2) { int sum = n1 % 10 + n2 % 10; if(flag) ++sum; flag = false; if(sum > 9) { flag = true; ++count; } n1 /= 10; n2 /= 10; } if(count == 0) cout << "No carry operation." << endl; else if(count == 1) cout << "1 carry operation." << endl; else cout << count << " carry operations." << endl; } int main() { int n1, n2; while(cin >> n1 >> n2) { if(!n1 && !n2) break; output(n1, n2); } return 0; }
文章標籤
全站熱搜
創作者介紹
創作者 eric30 的頭像
eric30

*Our Blog*

eric30 發表在 痞客邦 留言(0) 人氣(0)