STL法大好

江清月近魂  •  23天前


#include <bits/stdc++.h>
using namespace std;
queue<int>q;
int main() {
	char s;
	while(1){
		cin>>s;
		if(s=='a'||s=='A'){
			int x;
			cin>>x;
			q.push(x);
		}
		else if(s=='N'||s=='n'){
			if(!q.empty()){
				cout<<"Visit the patient with number "<<q.front()<<endl;
				q.pop();
			}else cout<<"No patients."<<endl;
		}
		else if(s=='S'||s=='s'){
			if(q.empty())
				cout<<"No patients."<<endl;
			else{
				cout<<"No longer receive the patient queue, following patients:";
				while(!q.empty()){
					cout<<q.front()<<" ";
					q.pop();
				}
			}
			return 0;
		}
		else{
			cout<<"Input error!"<<endl;
		}
	}
	return 0;
}

评论:

请先登录,才能进行评论