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