直接插入排序——对单链表进行非递减排序(带头结点)c语言实现
/***************************
* author:vivi
* date: 19-09-09
****************************/
#include <stdio.h>
#include <stdlib.h>
// function:单链表递增直接插入排序
typedef struct Node
{
int data;
struct Node* next;
}Node,* SList;
void init_list(SList* head)
{
*head = (SList)malloc(sizeof(Node));
(*head)->next = NULL;
}
void CreatList(SList* head)
{
int x;
int flag = 1;
printf("input data end 0:\n");
单链表直接插入排序

本文介绍了一种使用C语言实现的单链表非递减排序算法——直接插入排序。该算法通过比较链表中元素的大小,将每个元素插入到已排序的正确位置,从而实现对单链表的排序。文章提供了完整的代码实现,包括初始化链表、创建链表、插入排序及打印排序后的链表。
最低0.47元/天 解锁文章
1445

被折叠的 条评论
为什么被折叠?



