Created
February 11, 2014 08:17
-
-
Save somratcste/8931015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
using namespace std; | |
int main() | |
{ | |
unsigned long a,b,count,carry,m; | |
while(scanf("%ld%ld",&a,&b)==2 && a!=0 && b!= 0) | |
{ | |
count=0,m=0; | |
while(a||b ) | |
{ | |
carry=a%10+b%10+m; | |
if(carry>9){ | |
m=10-carry; | |
count++; | |
} | |
a=a/10; | |
b=b/10; | |
} | |
if(count==0) | |
cout<<"No carry operation."<<endl; | |
else if(count==1) | |
cout<<"1 carry operations."<<endl; | |
else | |
printf("%d carry operation.\n",count); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment