From 388abf324ca231ba5713363637210f9ae09e5620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BD=AF=E5=AE=89=E7=A7=91=E6=8A=80=EF=BC=88SoftSec-Tech?= =?UTF-8?q?=EF=BC=89?= Date: Mon, 27 Oct 2025 12:28:16 +0800 Subject: [PATCH] Add basic calculator functionality in test1.cpp Implement a basic calculator using big_data_int class. --- test1.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test1.cpp diff --git a/test1.cpp b/test1.cpp new file mode 100644 index 0000000..b1c4244 --- /dev/null +++ b/test1.cpp @@ -0,0 +1,49 @@ +#include +#include "big_data_int.h" + +string getString(){ + auto* str = new string(); + str->reserve(100); + std::cout << "请输入内容:"; + std::cin.getline(str->c_str(), 100); // 直接读取到缓冲区 + + std::cout << "输入内容:" << str->c_str() << std::endl; + + return str; +} + +int main() +{ + cout<<"please input two numbers:"<>op; + big_data_int a(s_a), b(s_b), c; + switch (op.c_str()[0]) { + case '+': + c = a + b; + break; + case '-': + c = a - b; + break; + case '*': + c = a * b; + break; + case '/': + c = a / b; + break; + case '%': + c = a % b; + break; + default: + cout<<"Wrong operator input"<