-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathship.cpp
37 lines (33 loc) · 1009 Bytes
/
ship.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
int n;
cin >> n;
string name, classification;
vector <string> rat, womanchildren, man,captain;
while (n--)
{
cin >> name >> classification;
if(classification == "rat"){
rat.push_back(name);
}else if (classification == "woman"){
womanchildren.push_back(name);
}else if (classification == "child"){
womanchildren.push_back(name);
}else if (classification == "man"){
man.push_back(name);
}else if(classification == "captain"){
captain.push_back(name);
}
}
for(int i=0; i<int(rat.size());i++)
cout << rat[i] << "\n";
for(int i=0; i<int(womanchildren.size());i++)
cout << womanchildren[i]<< "\n";
for(int i=0; i<int(man.size());i++)
cout << man[i]<< "\n";
for(int i=0; i<int(captain.size());i++)
cout << captain[i]<< "\n";
}