Skip to content

Instantly share code, notes, and snippets.

@zxmarcos
Created October 16, 2016 13:41
Show Gist options
  • Save zxmarcos/80c781dca6c13ee3119510f2a02865a3 to your computer and use it in GitHub Desktop.
Save zxmarcos/80c781dca6c13ee3119510f2a02865a3 to your computer and use it in GitHub Desktop.
#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