33pts求条必玄关
查看原帖
33pts求条必玄关
1471193
kkksc24楼主2025/2/4 16:12
#include<bits/stdc++.h>
using namespace std;
stack<int> st;
int main(){
	char op;
	int tmp=0;
	while((op=getchar())!='@'){
		if(op>='0'&&op<='9')tmp=tmp*10+op-'0';
		if(op=='.')st.push(tmp),tmp=0;
		if(op=='+'){
			int b=st.top();
			st.pop();
			int a=st.top();
			st.pop();
			st.push(a+b);
		}
		if(op=='-'){
			int b=st.top();
			st.pop();
			int a=st.top();
			st.pop();
			st.push(a-b);
			break;
		}
		if(op=='*'){
			int b=st.top();
			st.pop();
			int a=st.top();
			st.pop();
			st.push(a*b);
		}
		if(op=='/'){
			int b=st.top();
			st.pop();
			int a=st.top();
			st.pop();
			st.push(a/b);
		}
	}
	printf("%d",st.top());
	return 0;
}

阳历1没过

2025/2/4 16:12
加载中...