59*684/-3*+#
57
#include<stdio.h>
#include<string.h>
#define N 100000
int main()
{
int top=-1;///表示栈空
char ch;
int a[N];
while(~scanf("%c",&ch))
{
if(ch=='#')
{
break;
}
else if(ch>='0'&&ch<='9')
{
a[++top]=ch-'0';///把字符类型转化为整形
}///a[++top]是进栈的操作
else
{
int x=a[top--];
int y=a[top];
if(ch=='+')
a[top]=y+x;
else if(ch=='-')
a[top]=y-x;
else if(ch=='*')
a[top]=y*x;
else if(ch=='/')
a[top]=y/x;
}
}
printf("%d\n",a[0]);
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/sh_tomorrow/article/details/47311115