Guest User

Untitled

a guest
Jan 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     long long int a,b,t;
  8.     int mod_b,mod_a,c;
  9.     while(1)
  10.     {
  11.         cin>>a>>b;
  12.  
  13.         if(a==0&&b==0)
  14.         break;
  15.  
  16.         c=0;
  17.  
  18.         int carry=0;
  19.         while(a||b)
  20.         {
  21.             mod_b=b%10;
  22.             mod_a=a%10;
  23.             if(mod_a+mod_b+carry>9)
  24.             {
  25.                 c++;
  26.                 b=b/10;
  27.                 a=a/10;
  28.                 carry=1;
  29.             }
  30.             else
  31.             {
  32.                 b=b/10;
  33.                 a=a/10;
  34.                 carry=0;
  35.             }
  36.         }
  37.  
  38.         if(c==0)
  39.         cout<<"No carry operation.";
  40.         else if(c==1)
  41.         cout<<"1 carry operation.";
  42.         else
  43.         cout<<c<<" carry operations.";
  44.         cout<<endl;
  45.     }
  46.     return 0;
  47. }
Add Comment
Please, Sign In to add comment