Back-order operation code instance and operation instance
C code)
# Define _ CRT_SECURE_NO_WARNINGS # include
# Include
Void jisuan (char *); float cal (float, float, char); void main () {char input [80]; printf ("Middle Order :"); scanf ("% s", input); jisuan (input); system ("pause");} void jisuan (char * arr) {float stack [80] ={ 0.0}; int top = 0; int I = 0; char op; char temp [2]; while (1) {op = arr [I]; switch (op) {case '\ 0': printf ("% f \ n", stack [top]); return; case '+': case '-': case '*': case '/': stack [top-1] = cal (stack [top], stack [top-1], op); top --; break; default: if (top <sizeof (stack)/sizeof (float) {temp [0] = op; top ++; stack [top] = atof (temp); // convert character to float} break;} I ++ ;}} float cal (float A, float B, char op) {if (op = '+') {return A + B;} if (op = '-') {return A-B ;} if (op = '*') {return A * B;} if (op = '/') {return A/B ;}}