-
-
Save RickCarlino/4275186 to your computer and use it in GitHub Desktop.
Blah. I just vomited c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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