tcbpg

Untitled

Oct 23rd, 2011
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     #ifdef ACM
  8.         freopen("test.in", "r", stdin);
  9.     #endif
  10.    
  11.     long long a,b; int carry,cont;
  12.     while(cin >> a >> b && !(a == 0 && b == 0)){
  13.         carry = cont = 0;
  14.         while(a > 0 || b > 0 || carry > 0){
  15.                 if(a % 10 + b % 10 + carry > 9) carry = 1; else carry = 0;
  16.                
  17.                 cont += carry;
  18.                
  19.                 a = a/10;
  20.                 b = b/10;
  21.         }
  22.        
  23.         switch(cont){
  24.                 case 0:
  25.                     cout << "No carry operation." << endl;
  26.                     break;
  27.                 case 1:
  28.                     cout << "1 carry operation." << endl;
  29.                     break;
  30.                 default:
  31.                     cout << cont << " carry operations." << endl;
  32.                     break;
  33.         }
  34.     }
  35.    
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment