-
Notifications
You must be signed in to change notification settings - Fork 14
/
10035.cpp
52 lines (41 loc) · 1.17 KB
/
10035.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<iostream>
using namespace std;
long long carry(long long n)
{
long long carry=0;
if(n>9)
carry =1;
else
carry =0;
return carry;
}
int main()
{
long long a,b,r1=0,r2=0,r=0,c=0,count=0;
for(;;)
{
cin>>a>>b;
if(a==0 && b==0)
break;
count =0;
r1=0;r2=0;r=0;
while((a!=0)||(b!=0))
{
r1=a%10;
r2=b%10;
a/=10;
b/=10;
r=r1+r2+c;
if(r>=9)
count++;
c=carry(r);
}
if(count>1)
cout<<count<<" carry operations."<<endl;
if(count==1)
cout<<"1 carry operation."<<endl;
if(count==0)
cout<<"No carry operation."<<endl;
}
return 0;
}