Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Inventory
//Title of this code // Map data structure exploration #include <iostream> #include <iterator> #include <algorithm> #include <utility> #include <cstring> #include <string> #include <map> #include <vector> using namespace std; typedef vector<string>Product; // key typedef map<Product::value_type, double>Inventory; int main() { Product item; item.resize(15); item[0] = "Couch LR"; item[1] = "Chair LR"; item[2] = "Table LR"; item[3] = "Side Table"; item[4] = "Table DR"; item[5] = "Chair DR"; item[6] = "China Cabinet"; item[7] = "Buffet"; item[8] = "Bed"; item[9] = "Dresser"; item[10] = "Night Stand"; item[11] = "TV Stand"; Inventory stock; stock.insert(make_pair(item[0], 2000)); stock.insert(make_pair(item[1], 1500)); stock.insert(make_pair(item[2], 500)); stock.insert(make_pair(item[3], 400)); stock.insert(make_pair(item[4], 600)); stock.insert(make_pair(item[5], 800.00)); stock.insert(make_pair(item[6], 3000.99)); stock.insert(make_pair(item[7], 5000.50)); stock.insert(make_pair(item[8], 1400.99)); stock.insert(make_pair(item[9], 2500.25)); stock.insert(make_pair(item[10], 600.69)); stock.insert(make_pair(item[11], 500.25)); Inventory::const_iterator price; cout << "\nItem\t\t\t\tPrice\n\n"; for(uint i=0; i<stock.size(); i++){ price = stock.find(item[i]); cout << price->first << "\t\t\t" << price->second << "\n"; } cout << "\n"; string searchWhat="Side Table"; int count = 0; for(uint i = 0; i < stock.size(); i++){ if(strcmp(searchWhat.c_str(), item[i].c_str()) == 0){ count = (int)i; break; } } price = stock.find(item[count]); cout << "item:\t\t" << price->first << "\nPrice/unit\t" << price->second << "\n"; }
run
|
edit
|
history
|
help
0
RegTokIt
C++ Solar eclipse program(Shoushi integrated) 1644 - 1785 from Ideone( Date: August 14, 2014 )
2015(M2)Simulare
map::swap()_30-Seconds-of-C++
scope new delete
Replace substring poor
Equilateral triangle
Program
DBeach Resort 4R8J-8P (State of Rio Grande.do Norte Brazil)
Breakfast Function