Advertisement
AlbertMourato

Untitled

Nov 21st, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <iomanip>
  4. using namespace std;
  5. int main(){
  6.    unsigned a, b;
  7.    int saida, q;
  8.    cin>>a>>b;
  9.    while(a!=0||b!=0){
  10.         saida = 0;
  11.         q = 0;
  12.         while(a>0||b>0){
  13.             int k = a%10+b%10+q;
  14.             q = k%10;
  15.             a/=10;
  16.             b/=10;
  17.             if(k>=10){
  18.                 saida++;
  19.             }
  20.         }
  21.         if(saida==0){
  22.             cout<<"No carry operation."<<"\n";
  23.         }else if(saida==1){
  24.             cout<<saida<<" carry operation."<<"\n";
  25.         }else{
  26.             cout<<saida<<" carry operations."<<"\n";
  27.         }
  28.         cin>>a>>b;
  29.    }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement