一个简单的计算器(c++)
2020-12-13 04:29
标签:long main double 选择 str splay 退出 bre cal #include class calc void input(); int jia(); //以下是对成员函数的定义 int calc::jian() int calc::mul() int calc::div() //long calc::pow() void calc::input() void calc::input1() void calc::input2() void calc::input3() void calc::input4() void calc::display1() void calc::display2() void calc::display_mul() void calc::display_div() int calc::display_pow(int q) //菜单 //退出菜单 ////////////主函数///////////// int c; while(1) 一个简单的计算器(c++) 标签:long main double 选择 str splay 退出 bre cal 原文地址:https://www.cnblogs.com/duanqibo/p/11111044.html
#include
using namespace std;
{
private:
int a,b;
int p,m;
public:
calc(){}
void input1();
void input2();
void input3();
void input4();
void input5();
double input6();
int jian();
int mul();
int div();
//long pow(); //平方
void display1(); //加
void display2(); //减
void display_mul();
void display_div();
int display_pow(int);
};
int calc::jia()
{
//int sum;
//sum=a+b;
//return sum;
return a+b;
}
{
return a-b;
}
{
return a*b;
}
{
if(b==0)
{
cout cout cin>>a>>b;
return 1;
}
else
return a/b;
}
//{
// return p*p;
//}
{
cout cin>>a>>b;
}
{
input();
jia();
}
{
input();
jian();
}
{
input();
mul();
}
{
input();
div();
}
/*
void calc::input5()
{
input();
pow();
}
*/
double calc::input6()
{
cout cin>>m;
double q=sqrt(m);
return q;
}
{
cout}
{
cout}
{
cout}
{
cout}
{
return q*q;
}
void menu()
{
cout cout cout cout cout cout cout cout cout cout cout cout cout cout cout cout cout cout cout}
void _exit()
{
cout cout cout cout cout cout cout cout}
int main()
{
calc add;
calc sub;
calc mul;
calc div;
calc pow;
calc sqrt;
menu(); //调用主菜单
{
cout cin>>c;
switch(c)
{
case 1:
add.input1();
add.display1();
break;
case 2:
sub.input2();
sub.display2();
break;
case 3:
mul.input3();
mul.display_mul();
break;
case 4:
div.input4();
div.display_div();
break;
case 5:
//pow.input5();
int p;
cout cin>>p;
cout break;
case 6:
cout break;
case 0:
system("cls");
_exit();
exit(1);
break;
default:
cout break;
}
}
return 1;
}
上一篇:Spring 创建增强类
下一篇:第4课 python基础语法