Created
October 16, 2016 13:41
-
-
Save zxmarcos/80c781dca6c13ee3119510f2a02865a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <map> | |
#include <regex> | |
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
int main(int argc, char *argv[]) | |
{ | |
std::ifstream input(argv[1]); | |
const std::regex title_regex("title=(\\d+)"); | |
std::smatch matcher; | |
std::map<int,std::string> sorted_titles; | |
std::string video; | |
while (std::getline(input, video)) { | |
if (std::regex_search(video, matcher, title_regex)) { | |
int no = std::stoi(matcher[1].str()); | |
sorted_titles[no] = video; | |
} | |
} | |
std::cout << "Valores ordenados" << std::endl; | |
for (auto pair : sorted_titles) { | |
std::cout << pair.first << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment