|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
04.12.2010, 21:46 | #1 |
Пользователь
Регистрация: 30.11.2010
Сообщений: 10
|
Структуры (сравнение)
Дана структура там есть поле ФИО, как раставить фамилии по алфавиту? Пробовал как со строками, выкидывает ошибку.
|
04.12.2010, 22:00 | #2 |
Форумчанин
Регистрация: 17.02.2010
Сообщений: 399
|
вот пример:
Код:
|
04.12.2010, 22:31 | #3 | |
Пользователь
Регистрация: 23.08.2010
Сообщений: 98
|
Достаточно переопределить оператор "меньше" для структур и воспользоваться сортировкой стандартного списка. В данном примере структуры вставляются в список в порядке, обратном алфавитному, и после сортировки упорядочены по алфавиту.
Код:
Цитата:
Последний раз редактировалось sergey.d; 04.12.2010 в 22:40. |
|
04.12.2010, 23:03 | #4 |
Пользователь
Регистрация: 30.11.2010
Сообщений: 10
|
Полное условие: Ведомость состоит из абитуриентов, сдавших вступительные экзамены в университет, содержит ФИО, адрес, оценки. Определить количество абитуриентов проживающих в городе минсе и сдавших экзамены со средним баллом не ниже 4,5, высести их фамилии в алфавитном порядке.
Код:
Последний раз редактировалось Stilet; 05.12.2010 в 13:29. |
05.12.2010, 03:28 | #5 |
Форумчанин
Регистрация: 07.01.2010
Сообщений: 141
|
и почему в наших вузах не учат использовать stl, или почему студенты сами не пытаются в ней полазить? ведь ясно же, что даже поверхностные знания позволяют избежать геморроя с динаммическими массивами, сортировками, поисками и прочими стандартными задачами.
вот как выглядит полное решение вашей задачи с использованием стл (заполнение списка студентов сделайте по вкусу). Если разберетесь, сэкономите себе кучу времени в будущем: Код:
|
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
В массиве из п элементов много совпадающих элементов. Найти количество различных элементов | Strax | Фриланс | 11 | 12.06.2010 20:13 |
Запрос на сравнение элементов строк. | Dobriak-ru | Microsoft Office Access | 2 | 31.03.2010 13:42 |
Найти максимальный из положительных элементов матрицы и сумму отрицательных элементов. | bessonov12 | Microsoft Office Excel | 7 | 04.05.2009 05:44 |
В одномерном массиве, состоящем из n вещественных элементов, вычислить сумму элементов массива | HazelHen | Общие вопросы C/C++ | 2 | 29.03.2009 15:16 |
Массив структур с заранее неизвестным количеством элементов, С++ | PersonaGrata | Общие вопросы C/C++ | 8 | 24.02.2008 16:34 |