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

Commit 3d6f8a0

Browse files
committed
U | 0.0.1.3-3 Update
1 parent 77ba7f2 commit 3d6f8a0

File tree

10 files changed

+219
-230
lines changed

10 files changed

+219
-230
lines changed

bin/MCT

32 Bytes
Binary file not shown.

src/MCT-Linux

-32.5 KB
Binary file not shown.

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
MCT-Build: main.cpp
1+
MCT-Build: main.cpp ./cpart/
22
g++ main.cpp -o ../bin/MCT

src/cpart/calc.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//calc函数,计算器
2+
void calc(){
3+
clear();
4+
char o;
5+
double num1,num2,num3;
6+
hy("计算器");
7+
print("\033[1;37;43m[NOTE]\033[0m:现仅只支持两个数之间的运算!","no",true);
8+
while (true){
9+
line("-",20,"yellow",true);
10+
print("请输入计算式(+ - * / ^),输入'0c0'退出","white",true);
11+
print("如: 1+1","white",true);
12+
cin >> num1 >> o >> num2;
13+
if (o == '+')
14+
printf("%f+%f=%f\n",num1,num2,num1+num2);
15+
//
16+
if (o == '-')
17+
printf("%f-%f=%f\n",num1,num2,num1-num2);
18+
//
19+
if (o == '*')
20+
printf("%f*%f=%f\n",num1,num2,num1*num2);
21+
//
22+
if (o == '/'){
23+
if (num2 != 0)
24+
printf("%f/%f=%f\n",num1,num2,num1/num2);
25+
else
26+
error();
27+
}
28+
//乘方
29+
/*
30+
if (o == '^') {
31+
int n=num2;
32+
if(num1 != 0 && num2 != 0){
33+
num3 = 1;
34+
while(n > 0) {
35+
int(num1)*int(num3)=num3;
36+
n--;
37+
}
38+
}
39+
else
40+
error();
41+
printf("%f^%f=%f\n",num1,num2,num3);
42+
}
43+
*/
44+
//退出
45+
if(o == 'c' && num1 == 0 && num2 ==0){
46+
clear();
47+
break;
48+
}
49+
//报错
50+
else
51+
error();
52+
}
53+
}

src/cpart/cg.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//E函数,几何计算
2+
void E(){
3+
hy("几何计算");
4+
while(true){
5+
line("-",20,"yellow",true);
6+
print("输入任意键继续,输入“\033[1;33mc\033[0m”退出...","no",true);
7+
cin >> q;
8+
if (q == 'c' || q == 'C'){
9+
clear();
10+
break;
11+
}
12+
else{
13+
//矩形 梯形 三角形 圆 面积,周长,体积
14+
}
15+
}
16+
}

src/cpart/chn.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//D函数,数值分析器
2+
void D(){
3+
clear();
4+
long double x, a;
5+
hy("数值分析器");
6+
while(true){
7+
line("-",20,"yellow",true);
8+
print("输入任意值继续,输入\033[1;33mC\033[0m退出...","no",true);
9+
cin >> q;
10+
if (q == 'c' || q == 'C'){
11+
clear();
12+
break;
13+
}
14+
else{
15+
print("请输入一个数:","blue",true);
16+
cin >> x;
17+
if (x == 0){
18+
cout << x << "是整数" << endl;
19+
cout << x << "是正数" << endl;
20+
cout << x << "不分质数合数" << endl;
21+
cout << x << "是偶数" << endl;
22+
}
23+
else{
24+
if (modf(x, &a) == 0.0)
25+
cout << x << "是整数" << endl;
26+
else
27+
cout << x << "是分数" << endl;
28+
if (x > 0)
29+
cout << x << "是正数" << endl;
30+
else
31+
cout << x << "是负数" << endl;
32+
if (x == 1)
33+
cout << x << "不分质数合数" << endl;
34+
if (int(x) - x != 0)
35+
cout << x << "不分质数合数" << endl;
36+
else{
37+
int n=0, i;
38+
for(i=2;i<x;i=i+1)
39+
if(int(x)%1 == 0)
40+
n=n+1;
41+
if (n >0)
42+
cout << x << "是合数" << endl;
43+
cout << x << "是质数" << endl;
44+
}
45+
if (int(x) == x){
46+
if (int(x) % 2 == 0)
47+
cout << x << "是偶数" << endl;
48+
cout << x << "是奇数" << endl;
49+
}
50+
else{
51+
if (x/2 - int(x)/2 == 0)
52+
cout << x << "是偶数" << endl;
53+
cout << x << "是奇数" << endl;
54+
}
55+
}
56+
}
57+
}
58+
}

src/cpart/maxn.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//B函数,计算最大公约数
2+
void B(){
3+
clear();
4+
double num3, num4;
5+
hy("最大公约数");
6+
print("\033[1;43;37m[NOTE]\033[0m:本功能只支持两个数之间的运算!","no",true);
7+
while(true){
8+
line("-",20,"yellow",true);
9+
print("输入任意值继续,输入\033[33;1mC\033[0m退出","no",true);
10+
cin >> q;
11+
if(q == 'c' || q == 'C'){
12+
clear();
13+
break;
14+
}
15+
else{
16+
print("请输入第一个数:","white",true);
17+
cin >> num3;
18+
print("请输入第二个数:","white",true);
19+
cin >> num4;
20+
num3 = abs(num3);
21+
num4 = abs(num4);
22+
while (num3 != num4){
23+
if (num3 > num4)
24+
num3 -= num4;
25+
else
26+
num4 -= num3;
27+
}
28+
cout << "这两个数的的最大公约数是: " << num3 + num4 << endl;
29+
}
30+
}
31+
}

src/cpart/minn.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//C函数,计算最小公倍数
2+
void C(){
3+
clear();
4+
hy("最小公倍数");
5+
print("\033[1;43;37m注意\033[0m:本功能只支持两个数之间的运算!","no",true);
6+
while(true){
7+
line("-",20,"yellow",true);
8+
print("输入任意值继续,输入\033[33;1mC\033[0m退出...","no",true);
9+
cin >> q;
10+
if(q == 'c' || q == 'C'){
11+
clear();
12+
break;
13+
}
14+
else{
15+
int n3;
16+
double num5, num6;
17+
while (true){
18+
print("请输入第一个数:","white",true);
19+
cin >> num5;
20+
print("请输入第二个数:","white",true);
21+
cin >> num6;
22+
if (num5 != int(num5) || num6 != int(num6))
23+
error();
24+
else
25+
break;
26+
}
27+
n3 = (num5 > num6) ? num5 : num6;
28+
while (true){
29+
if (n3 % int(num5) == 0 && n3 % int(num6) == 0){
30+
cout << "这两个数的的最小公倍数是:" << n3 << endl;
31+
break;
32+
}
33+
else
34+
++n3;
35+
}
36+
}
37+
}
38+
}

src/head/ECPPH.h renamed to src/head/mhead.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
#include <iostream>
22
#include <cmath>
33
#include <limits>
4-
#include <unistd.h>
5-
#include <ctime>
6-
#include <chrono>
74
#include <cstring>
85
#include <cstdio>
9-
#include <ios>
106
#include <string>
11-
#include <sys/types.h>
127
using namespace std;
138

149
int error(){
15-
printf("\033[1,31mERROR!\033[0m\a\n");
10+
cout << "\033[1,31mERROR!\033[0m\a\n";
1611
return 1;
1712
}
1813

19-
void clear(){
20-
printf("\033[2J");
21-
printf("\033[0,0");
22-
}
14+
void clear(){system("clear");}
2315

2416
void print(const char T[],string color,bool i){
2517
if(i==true){
@@ -91,3 +83,5 @@ void boxout(const char T[],string bc,string tc,bool i){
9183
}
9284
error;
9385
}
86+
void hy(const char T[]){cout<<"==> "<<T<<endl;}
87+
char q;

0 commit comments

Comments
 (0)