/
lyapdy
/
Object_oriented_programming_cpp_318
Обзор
Документация
Войти
/
lyapdy
/
Object_oriented_programming_cpp_318
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lab5/task_6.cpp
41 строка
1 KB
danillyapunov
some commit
21 авг 2025, 15:53
21 авг 2025, 15:53
a2fe910
Код
Авторство
О чём код?
#include <iostream> #include <string> #include <iostream> #include <vector> #include <algorithm> #include "task_6.h" bool cmp(const std::string lh, const std::string rh) { return lh.length() < rh.length(); } void task_6() { std::cout << "������� 6" << '\n'; std::vector<std::string> strings; std::string input; // ��६����� ��� ⮣�, �⮡� ���짮��⥫� ������ ��ப� ᨬ����� std::cout << "������ ��ப� (��� �����襭�� ������ ������ ��ப�):\n"; while (true) { std::getline(std::cin, input); // ���뢠�� ��ப�, ������ ���� if (input.empty()) { // ���塞, ����� �� ��ப� break; // ��室�� �� 横�� } strings.push_back(input); // ������塞 ��ப� � ����� } std::cout << "\n��室�� �������� �����: \t "; for (const auto& element : strings) { // ���⠥� १���� ����� std::cout << '|' << element << '|'; } sort(strings.begin(), strings.end(), cmp); // ����㥬 �� �᭮�� ����� ��ப� std::cout << "\n��������� �������� �����: "; for (const auto& element : strings) { // ���⠥� १���� ����� std::cout << '|' << element << '|'; } }