---
# System prepended metadata

title: 13487 - Big Integer
tags: [class]

---

# 13487 - Big Integer
###### tags: `class`
---

## Brief
See the code below

## Solution 0

```cpp=
#include <iostream>
#include <string>
#include "function.h"
using namespace std;

INT INT::operator=(INT x) {
    this->len = x.len;
    for (int i = 0; i < len; i++)
        this->data[i] = x.data[i];
    return *this;
}

INT INT::operator+(INT x) {
    int maxlen = this->len > x.len ? this->len + 1 : x.len + 1;
    for (int i = 0; i < maxlen - 1; i++)
        this->data[i] += x.data[i];
    this->data[maxlen - 1] = 0;
    for (int i = 0; i < maxlen - 1; i++) {
        if (this->data[i] > 9) {
            this->data[i + 1] += this->data[i] / 10;
            this->data[i] %= 10;
        }
    }
    for (int i = maxlen - 1; i >= 0; i--) {
        if (this->data[i] == 0) maxlen--;
        else break;
    }
    this->len = maxlen;
    return *this;
}

istream& operator>>(istream& input, INT &x) {
    string tmp;
    input >> tmp;
    x.len = tmp.size();
    for (int i = 0; i < x.len; i++)
        x.data[i] = tmp[x.len - i - 1] - '0';
    return input;
}

ostream& operator<<(ostream& output, INT x) {
    for (int i = x.len - 1; i >= 0; i--)
        output << (char) (x.data[i] + '0');
    return output;
}

// Utin
```

## Reference