逆波兰式也叫后缀表达式(将运算符写在操作数之后) 如:我们平时写a+b,这是中缀表达式,写成后缀表达式就是:ab+ 
先说明一下里面用到的基础
1.atof() 把字符串指针转化为浮点数
2.getchar有一个int型的返回值.当程序调用getchar时.程序就等着用户按键.用户输入的字符被存放在键盘缓冲区中.直到用户按回车为止(回车字符也放在缓冲区中).当用户键入回车之后,getchar才开始从stdio流中每次读入一个字符.getchar函数的返回值是用户输入的第一个字符的ASCII码,如出错返回-1,且将用户输入的字符回显到屏幕.如用户在按回车之前输入了不止一个字符,其他字符会保留在键盘缓存区中,等待后续getchar调用读取.也就是说,后续的getchar调用不会等待用户按键,而直接读取缓冲区中的字符,直到缓冲区中的字符读完为后,才等待用户按键.
3.getch与getchar基本功能相同,差别是getch直接从键盘获取键值,不等待用户按回车,只要用户按一个键,getch就立刻返回, getch返回值是用户输入的ASCII码,出错返回-1.输入的字符不会回显在屏幕上.getch函数常用于程序调试中,在调试时,在关键位置显示有关的结果以待查看,然后用getch函数暂停程序运行,当按任意键后程序继续运行.

Code
#include   <stdio.h>   
#include   <stdlib.h>   
#define     MAXOP     100   
#define     NUMBER     '0'   
int   getop   (char   []   );   
void   push   (double);   
double   pop(void);   
  
int main()   


{   
int   type;   
double   op2;   
char   s[MAXOP];   

while   ((type=getop(s))!=EOF)       
{   

     switch   (type)
{   
         case   NUMBER:   
                push(atof(s));
        break;   
  
         case   '+':   
                push(pop()+pop());   
                break;   
         case   '*':   
                push(pop()*pop());   
                break;   
         case   '-':   
                op2=pop();   
                push(pop()-op2);   
                break;   
     case   '\/':   
                op2=pop();   
                if   (op2!=0.0)   
                  push(pop()/op2);   
                else   
                  printf("error:zero   divisor\n");   
                break;   
         case   '\n':   
                printf("\t%.8g\n",pop());   
                break;   
         default:   
                printf("error:unknown   command   %s\n",s);   
                break;   
      }   
}   
return   0;   
}   
  
  
#define   MAXVAL   100   

int   sp=0;   
double   val[MAXVAL];   
  
void   push(double   f)   


{   
    if(sp<MAXVAL)   
        val[sp++]=f;   
    else   
        printf("error:stack   full,can't   push   %g\n",f);   
}   
double   pop(void)   


{   
    if   (sp>0)   
        return   val[--sp];   

    else   
{   
            printf("error:stack   empty\n");   
            return   0.0;   
            }   
}   
  
#include   <ctype.h>   
int   getch(void);   
void   ungetch(int);   
  
int   getop(char   s[])   


{   
    int   i,c;   
    while   ((s[0]=c=getch())==' '|| c=='\t');   
        s[1]='\0';   
    if(!isdigit(c)&&c!='.')   
        return   c;   
    i=0;   
    if(isdigit(c))   
        while   (isdigit(s[++i]=c=getch()));   
    if   (c=='.')   
        while   (isdigit(s[++i]=c=getch()));   
            s[i]='\0';   
    if   (c!=EOF)   
        ungetch(c);   
    return   NUMBER;   
}   
  
  
#define   BUFSIZE   100   
char   buf[BUFSIZE];   
int   bufp=0; 

int   getch(void)   


{   
    return(bufp>0) ? buf[--bufp]:getchar();   
}

void ungetch(int c)   


{   
    if (bufp>=BUFSIZE)   
        printf("ungetch:too   many   characters\n");   
    else   
        buf[bufp++]=c;   
}