Skip to content

Instantly share code, notes, and snippets.

@RickCarlino
Created December 13, 2012 09:18
Show Gist options
  • Save RickCarlino/4275186 to your computer and use it in GitHub Desktop.
Save RickCarlino/4275186 to your computer and use it in GitHub Desktop.
Blah. I just vomited c++
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <map>
using namespace std;
ifstream readStream;
string tempString;
string tempTitle;
int tempRating;
std::multimap<string, int> ratingItems;
multimap<string, int>::iterator it;
typedef pair<string, int> values;
int main()
{
readStream.open("input.txt");
if (readStream.is_open()) {
while(!readStream.eof()){
getline(readStream, tempTitle);
getline(readStream, tempString);
stringstream(tempString) >> tempRating;
ratingItems.insert(values(tempTitle, tempRating));
};
for(it=ratingItems.begin() ; it != ratingItems.end(); it++)
{
cout << it->first << " => " << it->second << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment