球球了,看看哪里错了
查看原帖
球球了,看看哪里错了
1416402
jiashuangqi_oh_no楼主2024/11/24 13:53
//P210
#include<iostream>
#include<stack>
using namespace std;
stack<int> sta;
int s=0,x=0,y=0;
int main(){
	char a;
	do{
		a=getchar();
		if(a<='9'&&a>='0'){
			s=s*10+a-'0';
		}
		else if(a=='.'){
			sta.push(s),s=0;
		}
		else if(a!='@'){
			x=sta.top(),sta.pop(),y=sta.top(),sta.pop();
			switch(a){
			case '+': sta.push(x+y);break;
			case '-': sta.push(x-y);break;
			case '*': sta.push(x*y);break;
			case '/': sta.push(x/y);break;
			}
		}
	}while (a!='@');
	cout<<sta.top();
	return 0;
}
2024/11/24 13:53
加载中...