?
查看原帖
?
760850
QWQ_jyc楼主2023/7/5 10:27
#include <bits/stdc++.h>
using namespace std;
stack<int>s; 
int m,n,e;
char a;
int main(){
	while(cin>>a){
        if(a=='@') break;
		if(a>='0'&&a<='9'){
			s.push(a); 
		}
		if(a=='+'){
			m=s.top();
			s.pop();
			n=s.top();
			s.pop();
			s.push(n+m);
            continue;
		}else if(a=='-'){
			m=s.top();
			s.pop();
			n=s.top();
			s.pop();
			s.push(n-m);
            continue;
		}else if(a=='*'){
			m=s.top();
			s.pop();
			n=s.top();
			s.pop();
			s.push(m*n);
            continue;
		}else if(a=='/'){
			m=s.top();
			s.pop();
			n=s.top();
			s.pop();
			s.push(n/m);
            continue;
		}else if(a=='.'){
			s.push(e);
            e=0;
            continue;
		}else {
			e=e*10+a-'0';
            continue;
		}
	}
	cout<<s.top();
    return 0;
}
2023/7/5 10:27
加载中...