-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuva10035
71 lines (64 loc) · 1.39 KB
/
uva10035
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using namespace std;
#include<iostream>
int main()
{
long long unsigned m,n,carry,count;
while (cin>>m>>n)
{
count=0,carry=0;
if(m==0&&n==0)
break;
while (m|| n)
{
carry=m%10+n%10+carry;
if(carry>9)
count++;
carry/=10;
m/=10;
n/=10;
}
if ( count)
{
if( count==1)
cout<<"1 carry operation."<<endl;
else
cout<<count<<" carry operations."<<endl;
}
else
cout<<"No carry operation."<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
long long unsigned int a,b,count,flag;
while(cin>>a>>b)
{
if(a==0&&b==0)
break;
count=0;
flag=0;
while(a||b)
{
flag=(a%10+b%10)+flag;
if(flag>9)
count++;
a=a/10;
b=b/10;
flag=flag/10;
}
if(count)
cout<<count<<" carry operations."<<endl;
else
cout<<"No carry operation."<<endl;
}
return 0;
}
/*if(!count)
cout<<"No carry operation."<<endl;
else if(count==1)
cout<<"1 carry operation."<<endl;
else
cout<<count<<" carry operations."<<endl;*/