Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
12/13 quiz shickes
#include <iostream> #include <string> #include <vector> #include <queue> #include <unordered_map> #include <iomanip> using namespace std; int main() { unordered_map<string, int> myFirstHash; cout <<" \n inserting 1,2,3,4 \n"; // 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 " ; } cout << " \n Trying fifth element which was not added: \n"; key = "5"; 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++) { cout << hashTablePtr->first << " " << hashTablePtr->second << endl; } }
run
|
edit
|
history
|
help
0
Breakfast Static Function
BInTree Traversal
cp.cpp
3
Rubix
/
Two pointer - MUST DO
ttt
cynb
Find Case Combinations of a String