@rangerx
1941 / 1550 / 141
Регистрация: 31.05.2009
Сообщений: 2,913
|
09.11.2011, 23:38
|
|
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| List sort(List head1)
{
List newList, cur, sel;
newList = NULL;
while(head1 != NULL)
{
sel = head1;
head1 = head1->next;
if((newList == NULL) || (sel->inf < newList->inf))
{
sel->next = newList;
newList = sel;
}
else
{
cur = newList;
while((cur->next != NULL) && (cur->next->inf < sel->inf))
cur = cur->next;
sel->next = cur->next;
cur->next = sel;
}
}
return newList;
} |
|
0
|