add c++11 (#87)

* binary search c++

* selection sort c++11

* c++ recursive countdown

* c++ recursion

* c++ quicksort

* rename folder names to c++11

* add another version of binary_search function

* c++11 hash tables

* c++11 breadth-first search
This commit is contained in:
umatbro
2018-10-18 17:25:54 +02:00
committed by Aditya Bhargava
parent 38f5b2792e
commit 7dc9e95d2a
15 changed files with 432 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#include <iostream>
#include <unordered_map>
#include <string>
#include <utility>
using std::cout;
using std::endl;
int main() {
std::unordered_map<std::string, float> book = {
{"apple", 0.67},
{"milk", 1.49},
{"avocado", 1.49}
};
// print book
for (std::pair<std::string, float> pair : book) {
cout << pair.first << ": " << pair.second << "$" << endl;
}
}

View File

@@ -0,0 +1,24 @@
#include <iostream>
#include <unordered_map>
#include <string>
using std::cout;
using std::endl;
std::unordered_map<std::string, bool> voted;
void check_voter(const std::string& name) {
auto search = voted.find(name);
if (search == voted.end() || search->second == false) {
voted.insert({name, true});
cout << "Let them vote!" << endl;;
} else {
cout << "Kick them out!" << endl;
}
}
int main() {
check_voter("tom");
check_voter("mike");
check_voter("mike");
}