diff --git a/include/int2048.h b/include/int2048.h index 3c18f13..d65c88b 100644 --- a/include/int2048.h +++ b/include/int2048.h @@ -2,56 +2,29 @@ #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; @@ -84,4 +57,4 @@ class int2048 { }; } // namespace sjtu -#endif +#endif \ No newline at end of file diff --git a/src/int2048.cpp b/src/int2048.cpp index a188b0f..a8d22c3 100644 --- a/src/int2048.cpp +++ b/src/int2048.cpp @@ -1,136 +1,159 @@ +/** + * @file int2048.cpp --- 2048-bit integer class implementation + * + * @details This file contains the implementation of the 2048-bit integer class. + * + * Codesytle: This file is written in a sytle mainly based on Google C++ Style + * Guide. As I use Clang-format to format my code, so the code style may be a + * little bit strange sometimes, in that case I'll manually format the + * code.What's sepecial is the comment: + * 1. Multi-line comments are always before the code they comment on. + * Usually the code they comment on is a complex procedure,like the definition + * of a function,a class or a variable with complex operation. If a multi-line + * comment is in one line, it will start with "/*" instead of "/**",otherwise it + * will start with "/**" and in the format of Doxygen. + * 2. Single-line comments are always after the code they comment on. + * Usually they are in the same line with the code they comment on,but sometimes + * they may come in the next lines. single-line comments shouldn't exceed 3 + * lines as they are intended to be short and easy to understand. + * 3. Temporary disabled code will be marked with "//" in the front of each + * 4. Some comments have special meanings,like "//TODO", "//FIXME", "//XXX","// + * clang-format off" and "// clang-format on". They are not controlled by the + * previous rules. + */ #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 &) { - // 实现大于等于运算符逻辑 - } +// 构造函数 +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 &) { + // 实现大于等于运算符逻辑 +} +} // namespace sjtu diff --git a/tester/tester.cpp b/tester/tester.cpp index fb408b6..5bd98b1 100644 --- a/tester/tester.cpp +++ b/tester/tester.cpp @@ -65,13 +65,13 @@ int main(int argc, char *argv[]) { } for (int i = 0; i < listed_cases.size(); i++) { std::cerr << "Testing " << listed_cases[i] << std::endl; - std::cerr << "Command " << index[listed_cases[i]] << std::endl; + std::cerr << "Command = " << index[listed_cases[i]] << std::endl; int status = system(index[listed_cases[i]].c_str()) / 256; if (status == 0) { std::cerr << "Test " << listed_cases[i] << " passed" << std::endl; } else { std::cerr << "Test " << listed_cases[i] << " failed" << std::endl; - std::cerr << "status code: " << status << std::endl; + std::cerr << "status code = " << status << std::endl; std::cerr << "Brief info: " << (config["StatusInterpreter"].contains(std::to_string(status)) @@ -83,6 +83,7 @@ int main(int argc, char *argv[]) { return 1; } } + std::cerr << '\n' << std::endl; } return 0; } \ No newline at end of file