Menu

From Cs142fa11

Revision as of 16:03, 16 November 2011 by Ldsawyer (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include <string>
#include <map>
 
using namespace std;
 
int main()
{
	map<string, double> scores;
	scores["Tom"] = 90;
	scores["Diana"] = 86;
	scores["Harry"] = 100;
	cout <<"Diana " << scores["Diana"]<<endl;
 
 
	map<string, vector<string>> food;
	vector<string> mark_diet;
	mark_diet.push_back("Spagetti");
	mark_diet.push_back("Mac and Cheese");
	mark_diet.push_back("Hogies");
	mark_diet.push_back("Bagels");
	food["Mark"] = mark_diet;
	vector<string> kevin_diet;
	kevin_diet.push_back("Steak");
	mark_diet.push_back("Steak");
	kevin_diet.push_back("Rice Bread");
	kevin_diet.push_back("Steak");
	kevin_diet.push_back("Salad");
	food["Kevin"] = kevin_diet;
	for (vector<string>::iterator food_it = food["Kevin"].begin(); food_it != food["Kevin"].end(); food_it++) {
		cout << *food_it << " ";
	}
	cout << endl;
	// Lets pick a few random meals for Kevin
	int menu;
	for(int i = 0; i < 10; i++) {
		menu = rand() % food["Kevin"].size(); 
		cout << "Picked Random Menu for Kevin "<<menu<<" " << food["Kevin"][menu]<<endl;
	}
 
	menu = rand()*food["Mark"].size()/RAND_MAX; 
	cout << "Picked Random Menu for Mark "<<menu<<" " << food["Mark"][menu]<<endl;
 
	// Now lets look at sets
	set <string> foodstuff;
	foodstuff.insert("Steak");
	foodstuff.insert("Spagetti");
	foodstuff.insert("Toast");
	for(set <string>::iterator nm = foodstuff.begin(); nm != foodstuff.end(); nm++) {
		cout << *nm<<endl;
	}
	cout <<"Count for Steak "<<foodstuff.count("Steak")<<endl;
	cout <<"Count for Brats "<<foodstuff.count("Brats")<<endl;
	system("pause");
}
Personal tools