Advertisement
Imran1107048

10035 -- Primary Arithmetic

Dec 28th, 2020
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. #define endl "\n"
  6. #define PI acos(-1.0)
  7. #define pb push_back
  8. #define mp make_pair
  9. #define all(v) v.begin(), v.end()
  10. #define IN freopen("input.txt",'r',stdin)
  11.  
  12. const int INF = 1e9+5;
  13. const int N = 205;
  14.  
  15. int32_t main()
  16. {
  17. while(1){
  18. int a,b;
  19. cin >> a >> b;
  20. if(a == 0 && b == 0)
  21. break;
  22. int cnt = 0, carry = 0;
  23. while(a>0 || b>0){
  24. int x = a%10;
  25. int y = b%10;
  26.  
  27. if(x+y+carry >= 10){
  28. cnt++;
  29. carry = 1;
  30. }
  31. else
  32. carry = 0;
  33. a/=10;
  34. b/=10;
  35. }
  36. if(cnt==0)
  37. cout << "No carry operation.\n";
  38. else if(cnt == 1)
  39. cout << "1 carry operation.\n";
  40. else
  41. cout << cnt << " carry operations.\n";
  42. }
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement