fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int m,n,c1,c2,acarreo=0,suma,cont=0;
  6.  
  7. while(cin>>n>>m && n && m){
  8.  
  9. cont=0;
  10. acarreo=0;
  11. while(0<n && 0<m){
  12. c1=n%10;
  13. c2=m%10;
  14. suma=c1+c2+acarreo;
  15. if(suma>=10){
  16. cont++;
  17. acarreo=1;
  18. }
  19. n=n/10;
  20. m=m/10;
  21. }
  22. if(cont==0){
  23. cout<<"No carry operation."<<endl;
  24. }
  25. else{
  26. if(cont==1) cout<<"1 carry operation."<<endl;
  27. else cout<<cont<<" carry operations."<<endl;
  28. }
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 16064KB
stdin
123 456
555 555
123 594
0 0
stdout
No carry operation.
3 carry operations.
1 carry operation.