#include<stdio.h>
#define list_size 20
typedef int keytype;
typedef int othertype;
typedef struct
{
keytype key;
othertype other_data;
}recordtype;
void inssort(recordtype r[],int length)
//對記錄陣列r做直接插入排序,length為陣列中待排序記錄的數目
{
int i,j;
for(i=2;i<=length;i++)
{
r[0]=r[i];
j=i-1;
while(r[0].key<r[j].key)
{
r[j+1]=r[j];
j=j-1;
}
r[j+1]=r[0];
}
}
void main()
{
int length,i;
recordtype r;
//輸入
for (i = 0; i < length; i++)
{
scanf("%d ",&r[i]);
}
printf("\n");
inssort(r,length);
//輸出
for (i = 0; i < length; i++) {
printf("%d", r[i]);
}
printf("\n");
}哪兒錯了呀
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/231862.html
標籤:C語言
上一篇:救救孩子
