diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..c7ee3e5 --- /dev/null +++ b/.clang-format @@ -0,0 +1,6 @@ +BasedOnStyle: Google +DerivePointerAlignment: false +PointerAlignment: Right +ColumnLimit: 80 +AllowCommentMovement: true +PenaltyBreakBeforeFirstCallParameter: 100 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07ed706 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 50e51b7..a7920f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.10) project(BigInt) -add_subdirectory(data) -add_subdirectory(src) \ No newline at end of file +add_subdirectory(src) +add_subdirectory(data) \ No newline at end of file diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 74ca77f..a75a0dc 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,7 +1,52 @@ set(PROJECT_NAME ${CMAKE_PROJECT_NAME}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "-g -O2") +set(ENV{MAKEFLAGS} "-j16") include_directories(${PROJECT_SOURCE_DIR}/include) link_directories(${PROJECT_SOURCE_DIR}/src) -add_executable(C1T1 Interger1/1.cpp) -target_link_libraries(C1T1 int2048) \ No newline at end of file +add_executable(C1T1 Integer1/1.cpp) +target_link_libraries(C1T1 int2048) +add_executable(C1T2 Integer1/2.cpp) +target_link_libraries(C1T2 int2048) +add_executable(C1T3 Integer1/3.cpp) +target_link_libraries(C1T3 int2048) +add_executable(C1T4 Integer1/4.cpp) +target_link_libraries(C1T4 int2048) +add_executable(C1T5 Integer1/5.cpp) +target_link_libraries(C1T5 int2048) +add_executable(C2T1 Integer2/1.cpp) +target_link_libraries(C2T1 int2048) +add_executable(C2T2 Integer2/2.cpp) +target_link_libraries(C2T2 int2048) +add_executable(C2T3 Integer2/3.cpp) +target_link_libraries(C2T3 int2048) +add_executable(C2T4 Integer2/4.cpp) +target_link_libraries(C2T4 int2048) +add_executable(C2T5 Integer2/5.cpp) +target_link_libraries(C2T5 int2048) +add_executable(C2T6 Integer2/6.cpp) +target_link_libraries(C2T6 int2048) +add_executable(C2T7 Integer2/7.cpp) +target_link_libraries(C2T7 int2048) +add_executable(C2T8 Integer2/8.cpp) +target_link_libraries(C2T8 int2048) +add_executable(C2T9 Integer2/9.cpp) +target_link_libraries(C2T9 int2048) +add_executable(C2T10 Integer2/10.cpp) +target_link_libraries(C2T10 int2048) +add_executable(C2T11 Integer2/11.cpp) +target_link_libraries(C2T11 int2048) +add_executable(C2T12 Integer2/12.cpp) +target_link_libraries(C2T12 int2048) +add_executable(C2T13 Integer2/13.cpp) +target_link_libraries(C2T13 int2048) +add_executable(C2T14 Integer2/14.cpp) +target_link_libraries(C2T14 int2048) +add_executable(C2T15 Integer2/15.cpp) +target_link_libraries(C2T15 int2048) +add_executable(C2T16 Integer2/16.cpp) +target_link_libraries(C2T16 int2048) +add_executable(C2T17 Integer2/17.cpp) +target_link_libraries(C2T17 int2048) +add_executable(C2T18 Integer2/18.cpp) +target_link_libraries(C2T18 int2048) \ No newline at end of file diff --git a/int2048.h b/int2048.h deleted file mode 100644 index 56511e8..0000000 --- a/int2048.h +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once -#ifndef SJTU_BIGINTEGER -#define SJTU_BIGINTEGER - -// Integer 1: -// 实现一个有符号的大整数类,只需支持简单的加减 - -// Integer 2: -// 实现一个有符号的大整数类,支持加减乘除,并重载相关运算符 - -// 请不要使用除了以下头文件之外的其它头文件 -#include -#include -#include -#include -#include - -// 请不要使用 using namespace std; - -namespace sjtu { -class int2048 { - // todo -public: - // 构造函数 - int2048(); - int2048(long long); - int2048(const std::string &); - int2048(const int2048 &); - - // 以下给定函数的形式参数类型仅供参考,可自行选择使用常量引用或者不使用引用 - // 如果需要,可以自行增加其他所需的函数 - // =================================== - // Integer1 - // =================================== - - // 读入一个大整数 - void read(const std::string &); - // 输出储存的大整数,无需换行 - void print(); - - // 加上一个大整数 - int2048 &add(const int2048 &); - // 返回两个大整数之和 - friend int2048 add(int2048, const int2048 &); - - // 减去一个大整数 - int2048 &minus(const int2048 &); - // 返回两个大整数之差 - friend int2048 minus(int2048, const int2048 &); - - // =================================== - // Integer2 - // =================================== - - int2048 operator+() const; - int2048 operator-() const; - - int2048 &operator=(const int2048 &); - - int2048 &operator+=(const int2048 &); - friend int2048 operator+(int2048, const int2048 &); - - int2048 &operator-=(const int2048 &); - friend int2048 operator-(int2048, const int2048 &); - - int2048 &operator*=(const int2048 &); - friend int2048 operator*(int2048, const int2048 &); - - int2048 &operator/=(const int2048 &); - friend int2048 operator/(int2048, const int2048 &); - - int2048 &operator%=(const int2048 &); - friend int2048 operator%(int2048, const int2048 &); - - friend std::istream &operator>>(std::istream &, int2048 &); - friend std::ostream &operator<<(std::ostream &, const int2048 &); - - friend bool operator==(const int2048 &, const int2048 &); - friend bool operator!=(const int2048 &, const int2048 &); - friend bool operator<(const int2048 &, const int2048 &); - friend bool operator>(const int2048 &, const int2048 &); - friend bool operator<=(const int2048 &, const int2048 &); - friend bool operator>=(const int2048 &, const int2048 &); -}; -} // namespace sjtu - -#endif diff --git a/src/int2048.cpp b/src/int2048.cpp index e69de29..a188b0f 100644 --- a/src/int2048.cpp +++ b/src/int2048.cpp @@ -0,0 +1,136 @@ +#include "int2048.h" + +namespace sjtu { + // 构造函数 + int2048::int2048() { + // 实现构造函数逻辑 + } + + int2048::int2048(long long) { + // 实现构造函数逻辑 + } + + int2048::int2048(const std::string &) { + // 实现构造函数逻辑 + } + + int2048::int2048(const int2048 &) { + // 实现构造函数逻辑 + } + + // 读入一个大整数 + void int2048::read(const std::string &) { + // 实现读取逻辑 + } + + // 输出储存的大整数,无需换行 + void int2048::print() { + // 实现输出逻辑 + } + + // 加上一个大整数 + int2048 &int2048::add(const int2048 &) { + // 实现加法逻辑 + } + + // 返回两个大整数之和 + int2048 add(int2048, const int2048 &) { + // 实现加法逻辑 + } + + // 减去一个大整数 + int2048 &int2048::minus(const int2048 &) { + // 实现减法逻辑 + } + + // 返回两个大整数之差 + int2048 minus(int2048, const int2048 &) { + // 实现减法逻辑 + } + + // 运算符重载 + + int2048 int2048::operator+() const { + // 实现一元加法逻辑 + } + + int2048 int2048::operator-() const { + // 实现一元减法逻辑 + } + + int2048 &int2048::operator=(const int2048 &) { + // 实现赋值运算符逻辑 + } + + int2048 &int2048::operator+=(const int2048 &) { + // 实现复合加法逻辑 + } + + int2048 operator+(int2048, const int2048 &) { + // 实现加法逻辑 + } + + int2048 &int2048::operator-=(const int2048 &) { + // 实现复合减法逻辑 + } + + int2048 operator-(int2048, const int2048 &) { + // 实现减法逻辑 + } + + int2048 &int2048::operator*=(const int2048 &) { + // 实现复合乘法逻辑 + } + + int2048 operator*(int2048, const int2048 &) { + // 实现乘法逻辑 + } + + int2048 &int2048::operator/=(const int2048 &) { + // 实现复合除法逻辑 + } + + int2048 operator/(int2048, const int2048 &) { + // 实现除法逻辑 + } + + int2048 &int2048::operator%=(const int2048 &) { + // 实现复合取模逻辑 + } + + int2048 operator%(int2048, const int2048 &) { + // 实现取模逻辑 + } + + std::istream &operator>>(std::istream &, int2048 &) { + // 实现输入运算符逻辑 + } + + std::ostream &operator<<(std::ostream &, const int2048 &) { + // 实现输出运算符逻辑 + } + + bool operator==(const int2048 &, const int2048 &) { + // 实现等于运算符逻辑 + } + + bool operator!=(const int2048 &, const int2048 &) { + // 实现不等于运算符逻辑 + } + + bool operator<(const int2048 &, const int2048 &) { + // 实现小于运算符逻辑 + } + + bool operator>(const int2048 &, const int2048 &) { + // 实现大于运算符逻辑 + } + + bool operator<=(const int2048 &, const int2048 &) { + // 实现小于等于运算符逻辑 + } + + bool operator>=(const int2048 &, const int2048 &) { + // 实现大于等于运算符逻辑 + } +}