adding cs142 code
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user