adding cs142 code

This commit is contained in:
dm
2016-04-06 20:45:34 -07:00
parent 552d456d53
commit 8e52ce1982
174 changed files with 14064 additions and 0 deletions
+43
View File
@@ -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;
}