Информатика, вопрос задал Vlad3259 , 7 лет назад

Написать программу на С++
Дан символьный файл f. Получить в файле g все малые латинские буквы файла f.

Ответы на вопрос

Ответил icYFTLRU
0

#include <iostream>

#include <regex>

#include <fstream>

#include <string>

using namespace std;

int main() {

   ifstream fin("f");

   string s = "", _temp;

   while (getline(fin, _temp))

       s += _temp;

   fin.close();

   ofstream fout("g");

   try {

       regex re("[a-z]");

       sregex_iterator next(s.begin(), s.end(), re);

       sregex_iterator end;

       while (next != end) {

           smatch match = *next;

           fout << match.str();

           next++;

       }

   }

   catch (regex_error& e) {

       cout << "smth went wrong.";

   }

   fout.close();

}

Ответил Vlad3259
0
Первый курс как бы,ещё такое не учили
Новые вопросы