📄 5-22.c
字号:
#include "stdio.h"
typedef int datatype;
typedef struct node{
datatype data;/*数据内容*/
int key;/*关键字*/
struct node *next;
} listnode;
typedef int Arrtype ;
listnode * binsort(Arrtype A[],int arr_num)
{ /*A要排序的数组,arr_num为数组大小*/
listnode *head,*q,*temp;
int i;
head=(listnode *)malloc(sizeof(listnode ));
head->key=-1;/*便于后面的比较*/
head->next=NULL;
i=0;
for(i;i<arr_num;i++)
{
q=head->next;
while(q)
{/*找到插入入口,插入结点*/
if((q->key<A[i])&&((q->next==NULL)||(q->next->key>A[i])))
{
temp=(listnode*)malloc(sizeof(listnode));
temp->data=A[i];
temp->key=A[i];
temp->next=q->next;
q->next=temp;
}
}
}
return(head);
}
void main()
{
int c[10];
listnode *node=binsort(c,10);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -