1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <cmath>
using namespace std;
void main()
{
int A,x;
double B,C,D;
for (A=1;A&lt;999999;A++)
{
cout< <"简单计算器,只能算2个数的值,可以是浮点数(小数)\n"
<<"输入1个数据后按空格键区分,2个都输入后按回车即可!\n";
cout<<"请输入计算类型:\n"
<<"1-加法\t"
<<"2-减法\t"
<<"3-乘法\t"
<<"4-除法\t"
<<"5-乘方\t"
<<"6-开方\t"
<<"7-退出程序!\n";
cout<<"输入代码后回车!\n";
cin>>x;
if (x==1)
{
cout< <"加法-请输入2个数:";
cin>>B>>C;
D=B+C;
cout< <"和为:"<<D<<endl<<"当前第"<<A<<"次运算!\n";
system("pause");
}
else if (x==2)
{
cout<<"减法-请输入2个数:";
cin>>B>>C;
D=B-C;
cout< <"差为:"<<D<<endl<<"当前第"<<A<<"次运算!\n";
system("pause");
}
else if (x==3)
{
cout<<"乘法-请输入2个数:";
cin>>B>>C;
D=B*C;
cout< <"积为:"<<D<<endl<<"当前第"<<A<<"次运算!\n";
system("pause");
}
else if (x==4)
{
cout<<"除法-请输入2个数:";
cin>>B>>C;
D=B/C;
cout< <"商为:"<<D<<endl<<"当前第"<<A<<"次运算!\n";
system("pause");
}
else if (x==5)
{
int i;
cout<<"乘方-请输入1个(a的a次方)或者2个数(a的b次方):\n";
cout<<"运算1个数,请输入1\n"<<"运算2个数,请输入2\n";
cin>>i;
if (i==1)
{
cout< <"请输入1个数:";
cin>>B;
double D=pow(B, B);
cout< <B<<"的"<<B<<"次方为:"<<D<<endl<<"当前第"<<A<<"次运算!\n";
system("pause");
}
else
{
cout<<"请输入2个数:";
cin>>B>>C;
double D=pow(B,C);
cout< <B<<"的"<<C<<"次方为:"<<D<<endl<<"当前第"<<A<<"次运算!\n";
system("pause");
}
}
else if (x==6)
{
cout<<"开方-请输入1个数:";
cin>>B;
double D=sqrt(B);
cout< <B<<"的开方为:"<<D<<endl<<"当前第"<<A<<"次运算!\n";
system("pause");
}
else if (x==7)
{
break;
}
else
{
cout<<"乱按没有任何效果!\t"<<"好吧,系统认为这个也算运算..\n"<<"当前第"<<A<<"次运算!\n";
system("pause");
}
}
system("echo 目前还不能让同一运算进行多次…\n");
system("echo 如果你有兴趣看下源代码(.cpp文件,记事本打开)的话,你会发现很多命令可以共用的.\n");
cout<<"最简计算器Ver0.1 By EVE丶光\n"<<"还在完善ing…\n"<<"程序退出!";
}