程序直接停止工作了?
查看原帖
程序直接停止工作了?
1003280
sunyining28楼主2023/12/4 18:01

我是犯了什么非常低级的重大的错误吗 编译过了 我输入第一个样例 打了一个enter 然后他跟我说程序未响应 停止工作……

这是本蒟蒻的代码 请大佬指教(✿◡‿◡)

帮忙解决了悬赏一个关注 谢谢

#include<bits/stdc++.h>
using namespace std;
char c;
int num,x,y;
stack<int> s;
int main(){
	while(cin>>c&&c!='@'){
		if(c!='+'&&c!='-'&&c!='*'&&c!='/'&&c!='.') num=num*10+c-'0';
		else{
			x=s.top();
			s.pop();
			y=s.top();
			s.pop();
			if(c=='+') s.push(x+y);
			else if(c=='-') s.push(y-x);
			else if(c=='*') s.push(x*y);
			else if(c=='/') s.push(y/x);
			else{
				s.push(num);
				num=0;
			}
		}
	}
	cout<<s.top();
	return 0;
}
2023/12/4 18:01
加载中...