C语言计算器源代码
- 格式:docx
- 大小:8.67 KB
- 文档页数:6
C++语言编写;; include<iostream>
include<cmath>
include<string>
using namespace std;
const double pi = 3.;
const double e = ;
const int SIZE = 1000; typedef struct node
{
i++;
ge = 0;
biao_dian = 1;
}
iflinei == 'P'
{
shu++p = pi;
i++;
break;
}
iflinei == 'E'
{
shu++p = e;
i++;
break;
}
ifflag1
{
h = h 10 + linei - '0';
flag = 1;
i++;
ifbiao_dian
ge++;
}
else
break;
}
ifflag
{
ifbiao_dian
{
int r = 1;
forint k = 1; k <= ge; k++
r = 10;
h /= r;
}
shu++p = h; + ^乘方 Foff Enter= "<<endl; cout<<"对于对数输入 L2_5 表示以2为底5的对数"<<endl;
cout<<"M在前面结果的基础上继续计算,如:上次结果为10,现输入+2"<<endl;
cout<<"D清零并继续输入"<<endl;
cout<<"F计算机关闭"<<endl;
cout<<"输入 P 就代表输入圆周率, 输入 E 代表输入自然对数"<<endl<<endl; }
void print
{
system"color 2";
cout<<" 欢迎使用本计算器"<<endl;
cout<<"输入一个字符串 on, 计算器开始启动"<<endl;
}
void if_start//是否启动计算器
{
string start;
print;
whilecin>>start
{
ifstart = "on"
{
cout<<"您所输入的字符无效, 请按照介绍的继续输入:"<<endl;
continue;
}
else
break;
}
ifstart == "on"
{
system"color 5";//颜色的处理
system"cls";//刷屏
}
introduce;//对计算器的简要介绍
cout<<"现在,请输入您所要计算的表达式"<<endl;
input;//输入所要计算的表达式
}
int main
{
if_start;//调用是否启动计算器函数return 0;
}。