-
Notifications
You must be signed in to change notification settings - Fork 0
/
1007.cpp
91 lines (85 loc) · 1.88 KB
/
1007.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <iostream>
using namespace std;
int main()
{
char a[250];
char b[250];
cin>>a>>b;
int end1,end2;
for(int i=0;i<250;++i)
if(a[i]=='\0')
{
end1 = i-1;
break;
}
for(int i=0;i<250;++i)
if(b[i]=='\0')
{
end2 = i-1;
break;
}
char result[250];
result[2]='.';
int count = 0;
char flag = '0';
while(true)
{
if(count == 2)
{
end1--;
end2--;
++count;
continue;
}
if(end1==(-1) && end2==(-1) )
{
if(flag=='1')
{
result[count] = '1';
result[count+1]='\0';
++count;
}
result[count]='\0';
break;
}
if(end1==(-1))
{
result[count] = b[end2] + flag -'0';
flag = '0';
if(result[count]-'0' >=10)
{
result[count] = result[count]-10;
flag = '1';
}
++count;
end2--;
continue;
}
else if(end2==(-1))
{
result[count] = a[end1] + flag -'0';
flag = '0';
if(result[count]-'0' >=10)
{
result[count] = result[count]-10;
flag = '1';
}
++count;
end1--;
continue;
}
result[count] = a[end1] -'0' + b[end2] + flag - '0';
flag = '0';
if(result[count]-'0' >=10)
{
result[count] = result[count]-10;
flag = '1';
}
end1--;
end2--;
++count;
}
for(int j=count-1;j>=0;--j)
cout<<result[j];
return 0;
}