📄 exp.cpp
字号:
#include"sop.h"
void main()
{
/*
Stack test_S=CreateStack();
int num;
for(int i=0;i<=4;i++)
{
scanf("%d",&num);
Push(test_S,num);
}
for(i=0;i<=4;i++)
{
Pop(test_S,num);
printf("%d\n",num);
}
printf("十进制转八进制");
scanf("%d",&num);
while(num){
Push(test_S,num%8);
num=num/8;
}
while(!IsEmptyStack(test_S))
{
Pop(test_S,num);
printf("%d",num);
}
*/
Stack OPTR=CreateStack(); //A stack of Operation
Push(OPTR,'#');
Stack OPND=CreateStack(); //A stack of Number
char c;
int theta; //the oparetion
int a,b,ct,num=0;
c=getchar();
while(c!='#'||((char)Top(OPTR)!='#'))
{
if(!In(c))
{
num=num*10+c-48; //convert the char to the int
c=getchar();
}
else
{ if(num!=0)
Push(OPND,num);
num=0;
//the first case
if(Precede((char)Top(OPTR),c)<0)
{
Push(OPTR,int(c));
c=getchar();
}
//second case
else if(Precede((char)Top(OPTR),c)==0)
{
Pop(OPTR,ct);
c=getchar();
}
else
//third case-- operate the expression
{
Pop(OPTR,theta);
Pop(OPND,b);
Pop(OPND,a);
Push(OPND,(Operate(a,char(theta),b)));
}
}
}
printf("%d",Top(OPND));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -