和题解挺像的但是本地也都是0
查看原帖
和题解挺像的但是本地也都是0
480877
Xiiii楼主2022/8/12 14:46
#include<bits/stdc++.h>
using namespace std;
stack <int> c;
string s;
int main() {
	cin>>s;
	for(int i=0;i<s.length();i++){
		int n=0;
		if(s[i]=='@') break;
		
		else if(s[i]>='0'&&s[i]<='9'){
			if(n!=0){
				n=n*10+s[i]-48;
			}
			else n=s[i]-48;
		}
		
		else if(s[i]=='.'){
			c.push(n);
			n=0;
		} 
		
		else{
			int x=c.top();
			c.pop();
			int y=c.top();
			c.pop();
			if(s[i]=='+') c.push(x+y);
			if(s[i]=='-') c.push(y-x);
			if(s[i]=='*') c.push(x*y);
			if(s[i]=='/') c.push(y/x);
		}
	
	}
	
	cout<<c.top();
	
	return 0;
}
2022/8/12 14:46
加载中...