#include <string.h>
char stack[100];
int top = 0;
void push(char ch);
char pop(void);
int main(void)
{
int i,n;
char str[100];
puts("Please input the expression");
gets(str);
n = strlen(str);
for(i = 0; i < n; i++)
{
if(str[i] == '(')
continue;
else if(str[i] >= '0' && str[i] <= '9')
putchar(str[i]);
else if((str[i] == '+') || (str[i] == '-') || (str[i] == '*'))
push(str[i]);
else if(str[i] == ')')
putchar(pop());
}
return 0;
}
void push(char ch)
{
stack[top++] = ch;
}
char pop(void)
{
return stack[--top];
}
[此贴子已经被作者于2022-6-1 00:54编辑过]