Advertisement
Guest User

10035wa

a guest
Sep 20th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     long int a,b;
  10.     int car,carcount;
  11.  
  12.     while((cin >> a >> b)&&(a!=0 && b!=0))
  13.     {
  14.         car = 0;
  15.         carcount =0;
  16.         while(a||b)
  17.         {
  18.             car = (a%10 + b%10+car)/10;
  19.             a = a/10;
  20.             b = b/10;
  21.             carcount = carcount + car;
  22.         }
  23.         if(carcount==0) cout << "No carry operation." << "\n";
  24.         else if(carcount==1) cout << "1 carry operation." << "\n";
  25.         else if(carcount>1) cout << carcount << " carry operations." << "\n";
  26.     }
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement