求一个简单的C++程序,最好带注释,什么都行

 我来答
RP大神ur0
2015-04-25 · TA获得超过285个赞
知道答主
回答量:105
采纳率:0%
帮助的人:110万
展开全部
#include<iostream> #include<cmath> int jie(int ); using namespace std; long int main() {L: char a; cout<<"a.求幂\n"<<"b.求e的多次方\n"<<"c.开根号\n"<<"d.求对数log\n"<<"e.求对数ln\n"<<"f.求三角函数\n"<<"g.阶乘\n"<<"h.加减乘除"<<endl; cout<<"选择:"; cin.clear(); cin>>a; switch(a) { case 'a':{double b,c;cout<<"输入底数:"; cin>>b; cout<<"输入次方:";cin>>c; cout<<b<<"^"<<c<<"="<<pow(b,c)<<endl; }break; case 'b':{double b;cout<<"输入e的次方";cin>>b; cout<<"e^"<<b<<"="<<exp(b);}break; case 'c':{double b;cout<<"输入要开平方的数:";cin>>b; cout<<"结果是:"<<sqrt(b)<<endl;}break; case 'd':{double b,d;cout<<"输入底数:";cin>>d; cout<<"输入真数:";cin>>b; cout<<"log"<<d<<"("<<b<<")="<<(log(b)/log(d))<<endl;}break; case 'e':{double b;cout<<"输入真数:";cin>>b; cout<<"ln"<<b<<"="<<log(b)<<endl;}break; case 'f':{char q;cout<<"a.sin()\n"<<"b.cos()\n"<<"c.tan()\n"<<"d.arcsin()\n"<<"e.arccos()\n"<<"f.arctan()\n"<<"g.cot()\n"<<"选择:"; cin>>q; switch(q) { case 'a':{double c;cout<<"输入角度";cin>>c; cout<<"sin"<<c<<"="<<sin(c)<<endl;}break; case 'b':{double c;cout<<"输入角度";cin>>c; cout<<"cos"<<c<<"="<<cos(c)<<endl;}break; case 'c':{double c;cout<<"输入角度";cin>>c; cout<<"tan"<<c<<"="<<tan(c)<<endl;}break; case 'd':{double c;cout<<"输入";cin>>c; cout<<"arcsin"<<c<<"="<<asin(c)<<endl;}break; case 'e':{double c;cout<<"输入";cin>>c; cout<<"arccos"<<c<<"="<<acos(c)<<endl;}break; case 'f':{double c;cout<<"输入";cin>>c; cout<<"arctan"<<c<<"="<<atan(c)<<endl;}break; case 'g':{double c;cout<<"输入角度";cin>>c; cout<<"cot"<<c<<"="<<(cos(c)/sin(c))<<endl;}break; default :cout<<"error"<<endl; }break; } case 'g':{int a;cout<<"输入:";cin>>a;cout<<"结果是:"<<jie(a)<<endl;}break; case 'h':{char ch;double m,n;cout<<"输入:";cin>>m>>ch>>n; switch (ch) {case '+':cout<<m<<"+"<<n<<"="<<m+n<<endl;break; case '-':cout<<m<<"-"<<n<<"="<<m-n<<endl;break; case '*':cout<<m<<"*"<<n<<"="<<m*n<<endl;break; case '/':cout<<m<<"/"<<n<<"="<<m/n<<endl;break; default :cout<<"error"<<endl; }break; default :cout<<"error"<<endl; } } cout<<endl; cout<<endl; goto L; } int jie(int n) { if(n==0)return 1; else return n*jie(n-1); } 实现简单的计算器功能
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式