#include <bits/stdc++.h>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
using namespace std;
const int N = 1005;
class Bigint
{
public:
int data[N], length;
Bigint()
{
length = 1;
memset(data, 0, sizeof data);
}
void set(const char* num);
void set(const int num);
Bigint(const int);
Bigint(const string);
Bigint(const Bigint&);
int operator[](int index) const { return data[index]; };
Bigint& operator=(const Bigint&);
Bigint operator+(const Bigint&) const;
Bigint operator-(const Bigint&) const;
Bigint operator*(const Bigint&) const;
Bigint operator/(const int&) const;
int operator%(const int&) const;
bool operator<(const Bigint&) const;
bool operator<(const int& t) const;
void print() const;
};
Bigint::Bigint(const string str) { this->set(str.c_str()); }
void Bigint::set(const char* num)
{
size_t l = strlen(num);
this->length = l;
for (int i = 0; i < l; i++) {
data[i] = num[l - i - 1] - '0';
}
}
void Bigint::set(const int num) { this->set(to_string(num).data()); }
void Bigint::print() const
{
for (int i = length - 1; i >= 0; i--) printf("%d", data[i]);
printf("\n");
}
Bigint Bigint::operator+(const Bigint& b) const
{
Bigint c;
auto& a = *this;
auto mlen = max(a.length, b.length);
for (int i = 0; i < mlen; i++) {
c.data[i] = a[i] + b[i];
c.data[i + 1] = c.data[i] / 10;
c.data[i] %= 10;
}
c.length = c[mlen] == 0 ? mlen : mlen + 1;
return c;
}
int main()
{
string as, bs;
cin >> as >> bs;
Bigint a(as), b(bs);
auto c = a + b;
c.print();
return 0;
}
测试0 0等均通过