求助!
查看原帖
求助!
536120
xxxzh28楼主2021/10/5 14:49
#include<bits/stdc++.h>
using namespace std;
string s;
int z,t,c=0,sta[10001000],a1,a2;
int sb(int x,int y){
	if(s[c]=='+')
	return x+y;
	if(s[c]=='-')
	return y-x;
	if(s[c]=='*')
	return x*y;
	if(s[c]=='/')
	return x/y;
}
int main(){
	getline(cin,s);
	while(s[c]!='@'){
		if(s[c]>='0'&&s[c]<='9')
			z=z*10+s[c]-'0';
			else
			{
			if(z!=0){
				sta[t++]=z;
				
				z=0;
			}
			else if(s[c]=='+'||s[c]=='-'||s[c]=='*'||s[c]=='/'){
				a2=sta[t];
				t-=1;
				a1=sta[t];
				sta[t]=sb(a1,a2);
				
				
			}
			
	      }
	      c+=1;
		}
	
	cout<<sta[t];
	return 0;
}
2021/10/5 14:49
加载中...