Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <Windows.h>
- #include <fstream>
- #include <map>
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- std::ifstream fin("eng-rus dictionary.txt");
- std::ofstream fout("rus-eng dictionary.txt");
- if (!fin.is_open() || !fout.is_open()) {
- std::cout << "Ошибка открытия файла" << std::endl;
- }
- else {
- std::vector<std::pair<std::string, std::string>> dict;
- std::pair<std::string, std::string> temp;
- fin >> temp.first >> temp.second;
- while (!fin.eof()) {
- dict.push_back(temp);
- fin >> temp.first >> temp.second;
- }
- std::sort(dict.begin(), dict.end(), [](const std::pair<std::string, std::string> & left, const std::pair<std::string, std::string> & right) {
- return left.second < right.second;
- });
- for (const auto& a : dict) {
- fout << a.second;
- for (int i = 0; i < 20 - a.second.size(); i++) {
- fout << " ";
- }
- fout << a.first << std::endl;
- }
- fin.close();
- fout.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement