?? 5-22.c
字號:
#include "stdio.h"
typedef int datatype;
typedef struct node{
datatype data;/*數(shù)據(jù)內(nèi)容*/
int key;/*關(guān)鍵字*/
struct node *next;
} listnode;
typedef int Arrtype ;
listnode * binsort(Arrtype A[],int arr_num)
{ /*A要排序的數(shù)組,arr_num為數(shù)組大小*/
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)
{/*找到插入入口,插入結(jié)點*/
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);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -