用户输入一个后缀表达式,程序计算该后缀表达式的值并输出结果:
/* postfix_expression.c */ #include "stack.h" #include <stdio.h> #include <stdlib.h> #include <ctype.h> int main() { int i, flag; char c, data_string[10]; float data, f1, f2, result; stack data_stack; data_stack = create_stack(100); printf("Please input a postfix expression: "); i = 0; for(c = getchar(); c != ' '; c = getchar()) { switch(c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': flag = 1; data_string[i++] = c; break; case ' ': if(flag == 1) { data_string[i] = '