-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjiafa.cpp
More file actions
56 lines (54 loc) · 1.21 KB
/
jiafa.cpp
File metadata and controls
56 lines (54 loc) · 1.21 KB
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
/*************************************************************************
> File Name: jiafa.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年03月01日 星期二 22时32分15秒
************************************************************************/
#include<cstring>
#include<iostream>
#include<stdio.h>
using namespace std;
struct Big_add
{
int d[600];
int len;
Big_add() {
this->len = 0;
memset(d, 0, sizeof(d));
}
Big_add(char s[])
{
memset(d, 0, sizeof(d));
this->len = strlen(s);
for(int i=0; i<this->len;i++)
{
d[this->len-i-1] = s[i] - '0';
}
}
Big_add operator +(const Big_add &t)
{
Big_add ans = Big_add();
for(int i=0; i<600; i++)
{
int c = t.d[i]+this->d[i];
ans.d[i] += c%10;
ans.d[i+1] += c/10;
}
int l = 599;
while(l > 0 && ans.d[l] == 0)
l--;
ans.len = l;
return ans;
}
};
char a[600];
char b[600];
int main()
{
cin>>a>>b;
Big_add aa = Big_add(a);
Big_add bb = Big_add(b);
Big_add cc = aa + bb;
for(int i=cc.len; i>=0; i--)
cout<<cc.d[i];
}