feat finish all preparation works
This commit is contained in:
@ -2,56 +2,29 @@
|
|||||||
#ifndef SJTU_BIGINTEGER
|
#ifndef SJTU_BIGINTEGER
|
||||||
#define SJTU_BIGINTEGER
|
#define SJTU_BIGINTEGER
|
||||||
|
|
||||||
// Integer 1:
|
|
||||||
// 实现一个有符号的大整数类,只需支持简单的加减
|
|
||||||
|
|
||||||
// Integer 2:
|
|
||||||
// 实现一个有符号的大整数类,支持加减乘除,并重载相关运算符
|
|
||||||
|
|
||||||
// 请不要使用除了以下头文件之外的其它头文件
|
|
||||||
#include <complex>
|
#include <complex>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// 请不要使用 using namespace std;
|
|
||||||
|
|
||||||
namespace sjtu {
|
namespace sjtu {
|
||||||
class int2048 {
|
class int2048 {
|
||||||
// todo
|
|
||||||
public:
|
public:
|
||||||
// 构造函数
|
|
||||||
int2048();
|
int2048();
|
||||||
int2048(long long);
|
int2048(long long);
|
||||||
int2048(const std::string &);
|
int2048(const std::string &);
|
||||||
int2048(const int2048 &);
|
int2048(const int2048 &);
|
||||||
|
|
||||||
// 以下给定函数的形式参数类型仅供参考,可自行选择使用常量引用或者不使用引用
|
|
||||||
// 如果需要,可以自行增加其他所需的函数
|
|
||||||
// ===================================
|
|
||||||
// Integer1
|
|
||||||
// ===================================
|
|
||||||
|
|
||||||
// 读入一个大整数
|
|
||||||
void read(const std::string &);
|
void read(const std::string &);
|
||||||
// 输出储存的大整数,无需换行
|
|
||||||
void print();
|
void print();
|
||||||
|
|
||||||
// 加上一个大整数
|
|
||||||
int2048 &add(const int2048 &);
|
int2048 &add(const int2048 &);
|
||||||
// 返回两个大整数之和
|
|
||||||
friend int2048 add(int2048, const int2048 &);
|
friend int2048 add(int2048, const int2048 &);
|
||||||
|
|
||||||
// 减去一个大整数
|
|
||||||
int2048 &minus(const int2048 &);
|
int2048 &minus(const int2048 &);
|
||||||
// 返回两个大整数之差
|
|
||||||
friend int2048 minus(int2048, const int2048 &);
|
friend int2048 minus(int2048, const int2048 &);
|
||||||
|
|
||||||
// ===================================
|
|
||||||
// Integer2
|
|
||||||
// ===================================
|
|
||||||
|
|
||||||
int2048 operator+() const;
|
int2048 operator+() const;
|
||||||
int2048 operator-() const;
|
int2048 operator-() const;
|
||||||
|
|
||||||
|
@ -1,3 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* @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"
|
#include "int2048.h"
|
||||||
|
|
||||||
namespace sjtu {
|
namespace sjtu {
|
||||||
@ -133,4 +156,4 @@ namespace sjtu {
|
|||||||
bool operator>=(const int2048 &, const int2048 &) {
|
bool operator>=(const int2048 &, const int2048 &) {
|
||||||
// 实现大于等于运算符逻辑
|
// 实现大于等于运算符逻辑
|
||||||
}
|
}
|
||||||
}
|
} // namespace sjtu
|
||||||
|
@ -65,13 +65,13 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < listed_cases.size(); i++) {
|
for (int i = 0; i < listed_cases.size(); i++) {
|
||||||
std::cerr << "Testing " << listed_cases[i] << std::endl;
|
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;
|
int status = system(index[listed_cases[i]].c_str()) / 256;
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
std::cerr << "Test " << listed_cases[i] << " passed" << std::endl;
|
std::cerr << "Test " << listed_cases[i] << " passed" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Test " << listed_cases[i] << " failed" << std::endl;
|
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
|
std::cerr
|
||||||
<< "Brief info: "
|
<< "Brief info: "
|
||||||
<< (config["StatusInterpreter"].contains(std::to_string(status))
|
<< (config["StatusInterpreter"].contains(std::to_string(status))
|
||||||
@ -83,6 +83,7 @@ int main(int argc, char *argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::cerr << '\n' << std::endl;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Reference in New Issue
Block a user