只有50,大佬有时间帮忙看一下吧qwq
查看原帖
只有50,大佬有时间帮忙看一下吧qwq
470484
敲代码的憨仔楼主2021/10/3 14:46
#include<iostream>
#include<stack>
using namespace std;
stack<int>s;
int x,y,z;
int num=0;
int k=0;
int main(){
	char ip;
	while(ip!='@'){
	    ip=getchar();
		if(ip>='0'&&ip<='9')
		{
			k=k*10+ip-'0';
			
		}
		else if(ip=='.'){
		s.push(k);
		k=0;
		continue;
		}
		else if(ip=='+'){
			x=s.top();
			s.pop();
			y=s.top();
			s.pop();
			z=x+y;
			s.push(z);
		}
		else if(ip=='-'){
			x=s.top();
			s.pop();
			y=s.top();
			s.pop();
			z=y-x;
			s.push(z);
		}
		else if(ip=='*'){
			x=s.top();
			s.pop();
			y=s.top();
			s.pop();
			z=x*y;
			s.push(z);
		}
		else if(ip=='/'){
			x=s.top();
			s.pop();
			y=s.top();
			s.pop();
			z=y/z;
			s.push(z);
		}
	}
	cout<<s.top()<<endl;
	return 0;
}
2021/10/3 14:46
加载中...