school/cs142/lab08/test.cc

44 lines
925 B
C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
ostream & operator<<(ostream & os, vector<string> & v) {
os << "[";
for(auto &i: v) {
os << i << ", ";
}
os << "]";
return os;
}
int main() {
vector<string> people = {
"bilbo",
"frodo",
"samwise",
"gandalf",
"aragorn",
"aowen",
"gollum",
"gimli",
"legalos",
};
cout << people << endl;
vector<string>::iterator it = find(people.begin(), people.end(), "gandalf");
if(it != people.end())
people.erase(it);
cout << people << endl;
it = find(people.begin(), people.end(), "frodo");
if(it != people.end())
people.erase(it);
cout << people << endl;
it = find(people.begin(), people.end(), "Lord Voldemort");
if(it != people.end())
people.erase(it);
cout << people << endl;
}