求一个简单计算器的C语言程序
来源:百度知道 编辑:UC知道 时间:2024/05/21 12:06:51
在功能上功能尽量模拟windows操作系统中的计算器
#include
#include
#include
#include
#define MaxQSize 80
float qlist[MaxQSize],qlist1[MaxQSize],qlist2[MaxQSize]; //定义三个全局队列
int front=0,rear=0,front1=0,front2=0,rear1=0,rear2=0,count=0,count1=0,count2=0;//定义三个队列头结点、尾结点、数据个数
main()
{
char c[80];
void Enter(float),pop(),ClearStack();
printf("input string:(n:sin,o:cos,s:sqrt)\n");
while(gets(c),*c!='q' ||*c!='Q')
{
switch(*c)
{
case '+':
case '*':
case 's':
case 'n': //求SIN
case 'o': //求COS
case '/': //将符号入第一个队列
{
if(count==MaxQSize)
{
printf("Quere overflow!");
exit(1);
}
count++;
qlist[rear]=*c;
rear=(rear+1)%MaxQSize;
break;}
case '-':
{
if(strlen(c)>1) //如果是负号,则将负号和数一起入第二个队列
Enter(at