我为什么错了!!

liujiayu 2024-06-30 11:32:52 5

#include<bits/stdc++.h> using namespace std; int main(){ freopen("A.in","r",stdin); freopen("A.out","w",stdout); int n,x; cin>>n; string a; queueq; for(int i=1;i<=n;i++){ cin>>a; if(a=="push"){ cin>>x; q.push(x); }else if(a=="pop"){ if(q.empty()==0){ q.pop(); }else{ cout<<"error"<<endl; } }else if(a=="front"){ if(q.empty()==0){ cout<<q.front()<<endl; } else{ cout<<"error"<<endl; } } if(a=="empty"){ if(q.empty()==0){ cout<<"empty"; } else{ cout<<"not empty"<<endl; } } if(a=="clear"){ while(!q.empty()){ q.pop(); } } }

return 0;

}

{{ vote && vote.total.up }}

共 1 条回复

root 站长
	if(q.empty()==0){
			cout<<"empty";	

这个 empty 没有加换行。