#include <stdio.h>
#include <stdlib.h>
#include <
malloc.h>
typedef struct Node
{
int data;
struct Node *
next;
}NODE;
void Create_List(NODE *
L)
{
int n;
NODE *p,*
r;
r=
L;
scanf("%d",&
n);
while(
1)
{
if(n<
0)
break;
p=(NODE*)
malloc(
sizeof(NODE));
p->data=
n;
p->next=r->
next;
r->next=
p;
r=
p;
scanf("%d",&
n);
}
}
void DispList(NODE *
L)
{
NODE *p=L->
next;
while(p!=
NULL)
{
printf("%d ",p->
data);
p=p->
next;
}
}
void Rise(NODE *
L)
{
NODE *pre,*p=L->
next;
NODE *r=p->
next;
p->next=
NULL;
p=
r;
while(p!=
NULL)
{
r=p->
next;
pre=
L;
while(pre->next!=NULL&&pre->next->data<p->
data)
pre=pre->
next;
p->next=pre->
next;
pre->next=
p;
p=
r;
}
}
void main()
{
NODE *
L;
L=(NODE*)
malloc(
sizeof(NODE));
L->next=
NULL;
printf("创建链表:\n");
Create_List(L);
printf("链表如下:\n");
DispList(L);
Rise(L);
printf("增序后的链表:\n");
DispList(L);
printf("\n");
}
转载于:https://www.cnblogs.com/919czzl/p/4437033.html
相关资源:各显卡算力对照表!