|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
31.10.2008, 13:21 | #1 |
Новичок
Джуниор
Регистрация: 31.10.2008
Сообщений: 1
|
Сортировка массива на Си
Доброго времени суток Нужна ваша помощь.
Задача следующая: есть массив в котором 100 элементов(каждый элемент-число), необходимо отсортировать их по возрастанию или убыванию. Какой алгоритм здесь применить? Заранее благодарен. Спасибо за внимание. |
31.10.2008, 14:27 | #2 |
Новичок
Джуниор
Регистрация: 31.10.2008
Сообщений: 2
|
еслиу у тебя 100 элементов...можно простым пузырьком и всё..будет быстро :-)
можешь вообще написать sort(a,a+100) , подключив перед этим #include<algorithm.h> |
01.11.2008, 08:24 | #3 |
Ну и что? :)
Форумчанин
Регистрация: 20.10.2008
Сообщений: 129
|
Header File
stdlib.h Category Memory and String Manipulation Routines Prototype void qsort(void *base, size_t nelem, size_t width, int (_USERENTRY *fcmp)(const void *, const void *)); Description Sorts using the quicksort algorithm. qsort is an implementation of the “median of three” variant of the quicksort algorithm. qsort sorts the entries in a table by repeatedly calling the user-defined comparison function pointed to by fcmp. base points to the base (0th element) of the table to be sorted. nelem is the number of entries in the table. width is the size of each entry in the table, in bytes. fcmp, the comparison function, must be used with the _USERENTRY calling convention. fcmp accepts two arguments, elem1 and elem2, each a pointer to an entry in the table. The comparison function compares each of the pointed-to items (*elem1 and *elem2), and returns an integer based on the result of the comparison. *elem1 < *elem2 fcmp returns an integer < 0 *elem1 == *elem2 fcmp returns 0 *elem1 > *elem2 fcmp returns an integer > 0 In the comparison, the less-than symbol (<) means the left element should appear before the right element in the final, sorted sequence. Similarly, the greater-than (>) symbol means the left element should appear after the right element in the final, sorted sequence. Return Value None.
Учиться, учиться и еще раз учиться
|
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Сортировка массива | Dagmaria | Общие вопросы C/C++ | 5 | 05.07.2008 00:23 |
Сортировка массива | Kraven | Общие вопросы Delphi | 3 | 25.06.2008 18:22 |
Сортировка массива...? | Roberto | Помощь студентам | 2 | 11.04.2008 13:32 |
Сортировка массива | RIO | Помощь студентам | 1 | 05.04.2008 17:39 |
Сортировка массива | MuRdErDoLL | Помощь студентам | 2 | 20.12.2006 00:58 |