求助dalao们!!!
查看原帖
求助dalao们!!!
309484
wgl2009楼主2021/4/10 15:53
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;
int zhan[1000000],top,t;
int a,b;      
int main()                                                                                                                                          
{
	string s;
	cin>>s;
	for(int i=1;i<s.length()-1;i++)
	{
		if(s[i]>='0'&&s[i]<='9')
		{
			t=t*10+(s[i]-'0');
			t=0;
		}
		if(s[i]=='.')
		{
			if(s[i]=='+')
			{
				b=zhan[--top];
				a=zhan[--top];
				zhan[t]=a+b;
			}
			if(s[i]=='-')
			{
				b=zhan[--top];
				a=zhan[--top];
				zhan[t]=a-b;
			}
			if(s[i]=='*')
			{
				b=zhan[--top];
				a=zhan[--top];
				zhan[t]=a*b;
			}
			if(s[i]=='/')
			{
				b=zhan[--top];
				a=zhan[--top];
				zhan[t]=a/b;
			}
		}		
	}
	cout<<zhan[t]<<endl;	
}

提交记录

2021/4/10 15:53
加载中...