Update Source File
This commit is contained in:
parent
587ad6a38a
commit
7dcbce15f6
Binary file not shown.
|
@ -0,0 +1,35 @@
|
|||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void myplus(int list1[], int list2[], int list1length, int list2length,
|
||||
int *count) {
|
||||
for (int i = 1, x = 0; i <= max(list1length, list2length); i++) {
|
||||
count[i] = list1[i] + list2[i];
|
||||
x = count[1] / 10;
|
||||
count[i] %= 10;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void init() {
|
||||
string snum1, snum2;
|
||||
cin >> snum1 >> snum2;
|
||||
int inum1[snum1.size()], inum2[snum2.size()];
|
||||
for (int i = 0; i < snum1.size(); i++) {
|
||||
inum1[i] = snum1.c_str()[i] - '0';
|
||||
}
|
||||
for (int i = 0; i < snum2.size(); i++) {
|
||||
inum2[i] = snum2.c_str()[i] - '0';
|
||||
}
|
||||
int count[max(snum1.size(), snum2.size()) + 1];
|
||||
myplus(inum1, inum2, snum1.size(), snum2.size(), count);
|
||||
for (int i = 0; i < max(snum1.size(), snum2.size()) + 1; i++) {
|
||||
cout << count[i];
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
init();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue