fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. long long a,b,c=0,d=0;
  6.  
  7. while(1){
  8. cin>>a>>b;
  9. if(a==0&&b==0)
  10. break;
  11. while(1){
  12. if(a%10+b%10+c>=10){
  13. c=(a%10+b%10+c)/10;
  14. d++;}
  15. else
  16. c=0;
  17. a=a/10;
  18. b=b/10;
  19. if(a==0&&b==0)
  20. break;
  21. }
  22. if(d==1){
  23. cout<<"1 carry operation."<<endl;
  24. d=0;}
  25. else if(d==0)
  26. cout<<"No carry operation."<<endl;
  27. else{
  28. cout<<d<<" carry operations."<<endl;
  29. d=0;}
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0s 3344KB
stdin
999 999
990 911
9099 1
99999 1111
2552 6662
621 1
9999 0 
43 16
0 0
stdout
3 carry operations.
2 carry operations.
2 carry operations.
5 carry operations.
2 carry operations.
No carry operation.
No carry operation.
No carry operation.