Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <stdexcept>
- using namespace std;
- namespace big_int {
- class BigInt {
- public:
- BigInt() = default;
- BigInt(const vector<int16_t>& digits)
- : digits_(digits.size()) {
- // цифра должна состоять из одной цифры (с) Конфуций
- for (size_t i = 0; i < digits.size(); ++i) {
- }
- }
- BigInt& operator*=(const BigInt& other) {
- // реализация
- *this;
- }
- const vector<int16_t>& GetDigits() const {
- return digits_;
- }
- private:
- vector<int16_t> digits_{ 0 };
- bool natural_ = true;
- };
- BigInt operator+(const BigInt& lhs, const BigInt& rhs);
- BigInt operator-(const BigInt& lhs, const BigInt& rhs);
- BigInt operator*(const BigInt& lhs, const BigInt& rhs);
- BigInt operator/(const BigInt& lhs, const BigInt& rhs);
- ostream& operator<<(ostream& out, const BigInt& value) {
- for (const int& digit : value.GetDigits()) {
- out << digit;
- }
- return out;
- }
- // возведение в степень exp
- BigInt Pow(const BigInt& value, int exp);
- namespace tests {
- void TestConstuctor();
- void TestOperatorSum();
- void TestPow();
- void AllTests();
- } // namespace tests
- } // namespace big_int
- int main() {
- using namespace big_int;
- int16_t value = 48;
- cout << value << endl;
- BigInt first({1,5,7,6,6,7,7,8,8,8,4,3,5,6,3});
- cout << first << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement