诸位大佬,救救孩子吧,孩子快疯了
查看原帖
诸位大佬,救救孩子吧,孩子快疯了
1024207
Anatolia0469楼主2023/10/17 18:18

我这个蒟蒻始终看不出来自己究竟错哪里了,改代码已经改的怀疑人生了

    #include<iostream>
	#include<queue>
	using namespace std;
	queue<int>q;
	int n,s,x;
	int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s==1){
			cin>>x;
			q.push(x);
		}else if(s==2){
			if(q.empty()){
				cout<<"ERR_CANNOT_POP"<<endl;
			}else{
				q.pop();
			}
		}else if(s==3){
			if(q.empty()){
				cout<<"ERR_CANNOT_POP"<<endl;
			}else{
				cout<<q.front()<<endl;
			}
		}else{
			cout<<q.size()<<endl;
		}
	}
	return 0;
}
2023/10/17 18:18
加载中...