Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <string>
- #include <Windows.h>
- using namespace std;
- void merge(ifstream &f1, ifstream &f2, ofstream &fRes)
- {
- string one[3], two[3];
- while (!f1.eof() && !f2.eof())
- {
- getline(f1, one[0], ':');
- getline(f1, one[1], ':');
- getline(f1, one[2]);
- getline(f2, two[0], ':');
- getline(f2, two[1], ':');
- getline(f2, two[2]);
- if (one[1] == two[0] && one[2] == two[1])
- fRes << one[0] << ':' << two[2] << endl;
- }
- }
- int main()
- {
- string file1path, file2path, fileResultPath;
- ifstream file1, file2;
- ofstream fileResult;
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- cout << "Путь к первому файлу > ";
- getline(cin, file1path);
- cout << "Путь ко второму файлу > ";
- getline(cin, file2path);
- cout << "Путь к файлу для записи результата > ";
- getline(cin, fileResultPath);
- file1.open(file1path);
- file2.open(file2path);
- fileResult.open(fileResultPath);
- if (file1.is_open() && file2.is_open())
- {
- merge(file1, file2, fileResult);
- cout << "Готово!\n";
- }
- else
- cout << "Проблема с открытием файлов!\n";
- file1.close();
- file2.close();
- fileResult.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement