Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

U | PreviewUpdate #15

Merged
merged 3 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/home/fts427/Git/MathCentralTool/src",
"program": "/home/fts427/Git/MathCentralTool/src/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
59 changes: 59 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
29 changes: 29 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc 生成活动文件",
"command": "/usr/bin/gcc",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
""
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
Binary file modified bin/MCT
Binary file not shown.
Binary file removed src/MCT-Linux
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MCT-Build: main.cpp
MCT-Build: main.cpp ./cpart/
g++ main.cpp -o ../bin/MCT
53 changes: 53 additions & 0 deletions src/cpart/calc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//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();
}
}
16 changes: 16 additions & 0 deletions src/cpart/cg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//E函数,几何计算
void E(){
hy("几何计算");
while(true){
line("-",20,"yellow",true);
print("输入任意键继续,输入“\033[1;33mc\033[0m”退出...","no",true);
cin >> q;
if (q == 'c' || q == 'C'){
clear();
break;
}
else{
//矩形 梯形 三角形 圆 面积,周长,体积
}
}
}
58 changes: 58 additions & 0 deletions src/cpart/chn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//D函数,数值分析器
void D(){
clear();
long double x, a;
hy("数值分析器");
while(true){
line("-",20,"yellow",true);
print("输入任意值继续,输入\033[1;33mC\033[0m退出...","no",true);
cin >> q;
if (q == 'c' || q == 'C'){
clear();
break;
}
else{
print("请输入一个数:","blue",true);
cin >> x;
if (x == 0){
cout << x << "是整数" << endl;
cout << x << "是正数" << endl;
cout << x << "不分质数合数" << endl;
cout << x << "是偶数" << endl;
}
else{
if (modf(x, &a) == 0.0)
cout << x << "是整数" << endl;
else
cout << x << "是分数" << endl;
if (x > 0)
cout << x << "是正数" << endl;
else
cout << x << "是负数" << endl;
if (x == 1)
cout << x << "不分质数合数" << endl;
if (int(x) - x != 0)
cout << x << "不分质数合数" << endl;
else{
int n=0, i;
for(i=2;i<x;i=i+1)
if(int(x)%1 == 0)
n=n+1;
if (n >0)
cout << x << "是合数" << endl;
cout << x << "是质数" << endl;
}
if (int(x) == x){
if (int(x) % 2 == 0)
cout << x << "是偶数" << endl;
cout << x << "是奇数" << endl;
}
else{
if (x/2 - int(x)/2 == 0)
cout << x << "是偶数" << endl;
cout << x << "是奇数" << endl;
}
}
}
}
}
31 changes: 31 additions & 0 deletions src/cpart/maxn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//B函数,计算最大公约数
void B(){
clear();
double num3, num4;
hy("最大公约数");
print("\033[1;43;37m[NOTE]\033[0m:本功能只支持两个数之间的运算!","no",true);
while(true){
line("-",20,"yellow",true);
print("输入任意值继续,输入\033[33;1mC\033[0m退出","no",true);
cin >> q;
if(q == 'c' || q == 'C'){
clear();
break;
}
else{
print("请输入第一个数:","white",true);
cin >> num3;
print("请输入第二个数:","white",true);
cin >> num4;
num3 = abs(num3);
num4 = abs(num4);
while (num3 != num4){
if (num3 > num4)
num3 -= num4;
else
num4 -= num3;
}
cout << "这两个数的的最大公约数是: " << num3 + num4 << endl;
}
}
}
38 changes: 38 additions & 0 deletions src/cpart/minn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//C函数,计算最小公倍数
void C(){
clear();
hy("最小公倍数");
print("\033[1;43;37m注意\033[0m:本功能只支持两个数之间的运算!","no",true);
while(true){
line("-",20,"yellow",true);
print("输入任意值继续,输入\033[33;1mC\033[0m退出...","no",true);
cin >> q;
if(q == 'c' || q == 'C'){
clear();
break;
}
else{
int n3;
double num5, num6;
while (true){
print("请输入第一个数:","white",true);
cin >> num5;
print("请输入第二个数:","white",true);
cin >> num6;
if (num5 != int(num5) || num6 != int(num6))
error();
else
break;
}
n3 = (num5 > num6) ? num5 : num6;
while (true){
if (n3 % int(num5) == 0 && n3 % int(num6) == 0){
cout << "这两个数的的最小公倍数是:" << n3 << endl;
break;
}
else
++n3;
}
}
}
}
14 changes: 4 additions & 10 deletions src/head/ECPPH.h → src/head/mhead.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
#include <iostream>
#include <cmath>
#include <limits>
#include <unistd.h>
#include <ctime>
#include <chrono>
#include <cstring>
#include <cstdio>
#include <ios>
#include <string>
#include <sys/types.h>
using namespace std;

int error(){
printf("\033[1,31mERROR!\033[0m\a\n");
cout << "\033[1,31mERROR!\033[0m\a\n";
return 1;
}

void clear(){
printf("\033[2J");
printf("\033[0,0");
}
void clear(){system("clear");}

void print(const char T[],string color,bool i){
if(i==true){
Expand Down Expand Up @@ -91,3 +83,5 @@ void boxout(const char T[],string bc,string tc,bool i){
}
error;
}
void hy(const char T[]){cout<<"==> "<<T<<endl;}
char q;
Loading