diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 3994b6e..3daaee6 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -21,12 +21,12 @@ jobs: cmake ../ echo "Done!" shell: sh - - name: Make build + - name: Ninja build run: | cd ${{ github.workspace }} ls cd build - make + ninja echo "Done!" shell: sh - name: Upload exec file diff --git a/.github/workflows/stable-build.yml b/.github/workflows/stable-build.yml index 5b16370..3736fbc 100644 --- a/.github/workflows/stable-build.yml +++ b/.github/workflows/stable-build.yml @@ -14,35 +14,22 @@ jobs: - uses: actions/checkout@v3 - name: build-linux run: make - working-directory: src/Stable + working-directory: src - name: Build MCT-Linux uses: actions/upload-artifact@v3.1.2 with: name: MCT-Linux - path: src/Stable/MCT-Linux - - macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - name: build-macos - run: make - working-directory: src/Stable - - name: Build MCT-Macos - uses: actions/upload-artifact@v3.1.2 - with: - name: MCT-Macos - path: src/Stable/MCT-Linux - + path: src/MCT-Linux + windows: runs-on: windows-latest steps: - uses: actions/checkout@v3 - name: build-windows run: g++ MCT-Windows.cpp -o MCT-Windows.exe - working-directory: src/Stable + working-directory: src - name: Build MCT-Windows uses: actions/upload-artifact@v3.1.2 with: name: MCT-Windows - path: src/Stable/MCT-Windows + path: src/MCT-Windows diff --git a/.gitignore b/.gitignore index 141afa7..af96791 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ .vscode build - diff --git a/README.md b/README.md index 7693c5f..c98a8df 100644 --- a/README.md +++ b/README.md @@ -26,15 +26,15 @@ A terminal-based math tool that runs on linux. This program is free and open source. We allow everyone to use the source code for enrichment, compilation, etc. But we don't take any responsibility for any problems! -⚠worn: This program is in developing and cannot be used for scientific precision calculations! If anything goes wrong, do so at your own risk! +⚠ Note: This program cannot be used for science! If anything goes wrong, do so at your own risk! ## ❔ How to use -Look in the GitAction and choose you need. +Look in the GitAction and choose waht you need. Or clone and compile by yourself. -📦 Compilation environment requirements: cmake, make, gcc +📦 Compilation environment requirements: cmake, ninja, gcc ## 🧑‍💻 Contribution and thanks diff --git a/README_zh.md b/README_zh.md index d43748a..1d19bfb 100644 --- a/README_zh.md +++ b/README_zh.md @@ -26,7 +26,7 @@ 本程序是免费开源的,此源代码可以随意使用。允许任何人使用源代码进行扩充,编译等操作。出现任何问题,本人不承担任何责任! -⚠注意:本程序处于开发阶段,不可用于科学的精密计算!如果出现任何问题,后果自负! +⚠ 注意:本程序处于开发阶段,不可用于科学的精密计算!如果出现任何问题,后果自负! ## ❔如何使用 @@ -34,7 +34,7 @@ 或自行拉取编译 -📦编译环境需求:cmake, make,gcc +📦编译环境需求:cmake, ninja,gcc ## 🧑‍💻感谢 @@ -53,4 +53,3 @@ 本项目使用了头文件[ECPPH](https://github.com/QuantumLS-Studio/ECPPH) 先前的版本参见[MathCentralTools](https://github.com/FTS427/MathCentralTools)(已归档🗃️) - diff --git a/change_log.md b/change_log.md index b1571df..04afebc 100644 --- a/change_log.md +++ b/change_log.md @@ -75,3 +75,7 @@ - 功能:移除对Windows、Mac平台的支持 - UI:部分微调 - 整体:简化代码逻辑,便于维护 +- v0.0.1.3-4 + - 功能:无 + - UI:部分调整 + - 整体:代码部分重写,采用ninja&cmake编译 diff --git a/make.sh b/make.sh index 98594e4..9e423bd 100755 --- a/make.sh +++ b/make.sh @@ -1,5 +1,5 @@ cmake -S . -B ./build && cd ./build && -make && +ninja && echo "Done!" && echo "Exec -> build/MCT" diff --git a/src/include/ecp.h b/src/include/ecp.h index 737efd7..c25c2d5 100644 --- a/src/include/ecp.h +++ b/src/include/ecp.h @@ -4,14 +4,18 @@ #include #include #include +#include using namespace std; int error(){ - cout << "\033[1,31mERROR!\033[0m\a\n"; + printf("\033[1,31mERROR!\033[0m\a\n"); return 1; } -void clear(){system("clear");} +int clear(){ + system("clear"); + return 0; +} void print(const char T[],string color,bool i){ if(i==true){ @@ -29,7 +33,8 @@ void print(const char T[],string color,bool i){ cout<<"\033[35m"< "< ","white",false); cin >> q; - if (q=='1') - calc(); + if (q=='1'){ + int a,b; + char o; + print("calc> ","white",false); + cin >>a>>o>>b; + while (a!='0'&&b!='0'&&o!='c'){ + cout << calc(a,b,o) < ","white",false); + cin >>a>>o>>b; + } + } if (q=='2') B(); if (q=='3') C(); if (q=='4') D(); -//if (u=='5')E(); if (q=='E'||q=='e') break; if (q=='A'||q =='a'){ diff --git a/src/module/calc.cpp b/src/module/calc.cpp new file mode 100644 index 0000000..b71dbca --- /dev/null +++ b/src/module/calc.cpp @@ -0,0 +1,29 @@ +#include +int calc(int fn, int bn, char o){ + if (o=='+') + return fn+bn; + if (o=='-') + return fn-bn; + if (o=='*') + return fn*bn; + if (o=='/'){ + if (fn==0) + error(); + else + return fn/bn; + } + if (o=='^'){ + if (fn==bn==0) + error(); + int value=fn; + for (size_t i = 0; i <= bn; i++) + { + value=fn*value; + } + return value; + } + else{ + error(); + return 0; + } +} diff --git a/src/plugins/cg.cpp b/src/module/cg.cpp similarity index 100% rename from src/plugins/cg.cpp rename to src/module/cg.cpp diff --git a/src/plugins/chn.cpp b/src/module/chn.cpp similarity index 100% rename from src/plugins/chn.cpp rename to src/module/chn.cpp diff --git a/src/plugins/maxn.cpp b/src/module/maxn.cpp similarity index 100% rename from src/plugins/maxn.cpp rename to src/module/maxn.cpp diff --git a/src/plugins/minn.cpp b/src/module/minn.cpp similarity index 100% rename from src/plugins/minn.cpp rename to src/module/minn.cpp diff --git a/src/plugins/calc.cpp b/src/plugins/calc.cpp deleted file mode 100644 index 92c9ea2..0000000 --- a/src/plugins/calc.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//calc函数,计算器 -void calc(){ - clear(); - char o; - double num1,num2,num3; - hy("计算器"); - print("\033[1;37;43m[NOTE]\033[0m:现仅只支持两个数之间的运算!","no",true); - while (true){ - line("-",20,"yellow",true); - print("请输入计算式(+ - * / ^),输入'0c0'退出","white",true); - print("如: 1+1","white",true); - cin >> num1 >> o >> num2; - if (o == '+') - printf("%f+%f=%f\n",num1,num2,num1+num2); - //减 - if (o == '-') - printf("%f-%f=%f\n",num1,num2,num1-num2); - //乘 - if (o == '*') - printf("%f*%f=%f\n",num1,num2,num1*num2); - //除 - if (o == '/'){ - if (num2 != 0) - printf("%f/%f=%f\n",num1,num2,num1/num2); - else - error(); - } - //乘方 - /* -if (o == '^') { -int n=num2; -if(num1 != 0 && num2 != 0){ -num3 = 1; -while(n > 0) { -int(num1)*int(num3)=num3; -n--; -} -} -else -error(); -printf("%f^%f=%f\n",num1,num2,num3); -} -*/ - //退出 - if(o == 'c' && num1 == 0 && num2 ==0){ - clear(); - break; - } - //报错 - else - error(); - } -}