mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1883.cpp
This commit is contained in:
parent
38d845470e
commit
74379325f9
45
QUSTOJ/1883.cpp
Normal file
45
QUSTOJ/1883.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include <iostream>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
struct pack
|
||||
{
|
||||
string man,woman;
|
||||
};
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
cin>>n;
|
||||
queue<string> manbus;
|
||||
queue<string> womanbus;
|
||||
string name,sexual;
|
||||
while(n--)
|
||||
{
|
||||
cin>>name>>sexual;
|
||||
if(sexual=="M")
|
||||
{
|
||||
manbus.push(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
womanbus.push(name);
|
||||
}
|
||||
}
|
||||
cout<<"The dancing partners are:"<<endl;
|
||||
while(!manbus.empty()&&!womanbus.empty())
|
||||
{
|
||||
cout<<womanbus.front()<<" "<<manbus.front()<<endl;
|
||||
manbus.pop();
|
||||
womanbus.pop();
|
||||
}
|
||||
if(!manbus.empty())
|
||||
{
|
||||
cout<<"The first man to get a partner is:"<<manbus.front()<<endl;
|
||||
}
|
||||
else if(!womanbus.empty())
|
||||
{
|
||||
cout<<"The first woman to get a partner is:"<<womanbus.front()<<endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user