school/cs142/lab08/test.cc

44 lines
925 B
C++
Raw Normal View History

2016-04-06 20:45:34 -07:00
#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;
}