CPE 4. Primary Arithmetic
user_3763047219
c_cpp
2 years ago
762 B
0
Indexable
Never
#include <iostream> using namespace std; #include <string> int main(){ int a,b; while(cin>>a>>b){ int count=0; int add=0; if(a!=0&&b!=0){ while(a>1||b>1){ if(a%10+b%10+add>=10){ count=count+1; add=1; } else{ add=0; } a=a/10; b=b/10; } if(count==0){ cout<<"No carry operation."<<endl; } else if(count==1){ cout<<"1 carry operation."<<endl; } else{ cout<<count<<" carry operations."<<endl; } } } }