• Програма С++ : Создайте односвязный список элементов типа CHAR. Удалите из списка все символы, не являющиеся буквой латинского алфавита.

Ответы 2

  • Можно сделать, дабы избежать лишнего конструирования объекта std::locale(), std::locale name; и в лямбда-функции вместо конструктора поставить name
    • Автор:

      barbie
    • 5 лет назад
    • 0
  • #include <iostream>

    #include <list>

    #include <algorithm>

    #include <iterator>

    #include <cctype>

    int main()

    {

       std::list<char> lt{'5', 'a', 'c','g', '7', 't', '!'};

       std::cout << std::endl;

       std::copy(lt.begin(), lt.end(), std::ostream_iterator<char>(std::cout, " "));

       lt.remove_if([](char& var1)

       {

           return !(std::tolower(var1, std::locale()) >= 'a' && std::tolower(var1, std::locale()) <= 'z');

       });

       std::cout << std::endl;

       std::copy(lt.begin(), lt.end(), std::ostream_iterator<char>(std::cout, " "));

    }

    answer img
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years