Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Quiz 12/13
#include <iostream> #include <string> #include <vector> #include <queue> #include <unordered_map> #include <iomanip> using namespace std; int main() { // be of double type unordered_map<string, int> myFirstHash; // string of 1 as key for value of 1 myFirstHash["1"] = 1; // ITEM 1 of quiz myFirstHash["2"] = 2; myFirstHash["3"] = 3; myFirstHash["4"] = 4; // NOTE below code should be looped, but was having trouble with converting to string so brute force // method was used... string key = "1"; auto hashPointer = myFirstHash.find(key); if (hashPointer == myFirstHash.end() ) { cout << key << " not found in hash table \n" << endl; // ITEM 3 of quiz } else { cout << key << " found in hash table \n " ; // ITEM 2 of quiz } key = "2"; hashPointer = myFirstHash.find(key); if (hashPointer == myFirstHash.end() ) { cout << key << " not found in hash table \n" << endl; } else { cout << key << " found in hash table \n " ; } key = "3"; hashPointer = myFirstHash.find(key); if (hashPointer == myFirstHash.end() ) { cout << key << " not found in hash table \n" << endl; } else { cout << key << " found in hash table \n " ; } key = "4"; hashPointer = myFirstHash.find(key); if (hashPointer == myFirstHash.end() ) { cout << key << " not found in hash table \n" << endl; } else { cout << key << " found in hash table \n " ; } // ITEM 4 of quiz cout << " \n Items in hash below: \n" ; for (auto hashTablePtr = myFirstHash.begin(); hashTablePtr != myFirstHash.end(); hashTablePtr++) { // itr works as a pointer to pair<string, double> // type itr->first stores the key part and // itr->second stroes the value part cout << hashTablePtr->first << " " << hashTablePtr->second << endl; } }
run
|
edit
|
history
|
help
0
cccc
Test Euler Graph
1
Decimal to Binary
kadane's algorithm
Simple enemy polimorphism
Gauss 4x4
threadpool03
2015(M2)Mod.
compute power to a number manually, and by using function.