停止工作
查看原帖
停止工作
741299
zhangshibo678楼主2022/7/19 08:18
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
stack <int> ch;
int main(){
	int i=0;
	string s;
   getline(cin,s);
    while(s[i]!='@')
    {
    	if(s[i]!='.'&&s[i]!='+'&&s[i]!='-'&&s[i]!='*'&&s[i]!='/'){		  
		ch.push (s[i]);
	   }
    	int x=ch.top(); ch.pop();
    	int y=ch.top(); ch.pop();
    	switch(s[i]){
    		case '+':ch.push(x+y);break;
    		case '-':ch.push(y-x);break;
		    case '*':ch.push(x*y);break;
			case '/':ch.push(y/x);break;
	 
    	}
    
    }	
	i++;
    int w=ch.top();
      cout<<w;
	return 0;
}

2022/7/19 08:18
加载中...