Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main() {
- setlocale(0, "");
- string nameInputFile;
- cout << "Введите имя входного файла: ";
- cin >> nameInputFile;
- ifstream inputFile(nameInputFile.c_str());
- if (!inputFile.is_open()) {
- cout << "Не удалось открыть входной файл" << endl;
- return 0;
- }
- string nameOutputFile;
- cout << "Введите имя выходного файла: ";
- cin >> nameOutputFile;
- ofstream outputFile(nameOutputFile.c_str());
- if (!outputFile.is_open()) {
- cout << "Не удалось открыть выходной файл" << endl;
- return 0;
- }
- string abc;
- while (!inputFile.eof()) {
- inputFile >> abc;
- if (abc[0] == abc[abc.length() - 1]) {
- outputFile << abc << endl;
- cout << abc << endl;
- }
- }
- inputFile.close();
- outputFile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement