#include
#include
struct node
{
int num;
struct node *next;
};
int main(void)
{
int i;
node *a = (node*)malloc(sizeof(node));
a->next = NULL;
node *t = a;
for(i = 0; i < 111; i++)
{
a->next = (node*)malloc(sizeof(node));
a = a->next;
a->next = NULL;
a->num = rand()%111;
}
node *b = (node*)malloc(sizeof(node));
b->next = NULL;
node *u = b;
node *x = NULL;
for(a = t->next; a != NULL; a = x)
{
x = a->next;
for(b = u; b->next != NULL; b = b->next)
{
if(b->next->num >= a->num)
break;
}
a->next = b->next;
b->next = a;
}
node *y = u->next;
while(y != NULL)
{
printf("%d ", y->num);
y = y->next;
}
system("pause");
}
表插入排序
最新推荐文章于 2024-06-05 18:16:56 发布