RE求大佬帮调
查看原帖
RE求大佬帮调
1033548
xczsxczs楼主2023/12/1 20:05
#include<bits/stdc++.h>
using namespace std;
stack<int> s;
int c,x,y,l;
char a[51];
int main(){
	cin>>a;
	for(int i=0;i<strlen(a);i++){
		if(a[i]=='@'){cout<<s.top();return 0;}
		if(a[i]=='+')x=s.top(),s.pop(),y=s.top(),s.pop(),s.push(x+y);
		if(a[i]=='-')x=s.top(),s.pop(),y=s.top(),s.pop(),s.push(y-x);
		if(a[i]=='*')x=s.top(),s.pop(),y=s.top(),s.pop(),s.push(x*y);
		if(a[i]=='/')x=s.top(),s.pop(),y=s.top(),s.pop(),s.push(y/x);
		if(a[i]!='+'&&a[i]!='-'&&a[i]!='*'&&a[i]!='/'){
			while(a[i]!=' ')c=c*10+a[i++]-'0';
			if(c>0&&a[i]=='.')s.push(c),c=0;
		}
	}
}
2023/12/1 20:05
加载中...