Home > Back-end >  Direct insertion sort
Direct insertion sort

Time:12-09

#include
# define list_size 20
Typedef int keytype;
Typedef int othertype;
Typedef struct
{
Keytype key;
Othertype other_data;
} recordtype;
Void inssort (recordtype r [], int length)
//to record an array r do direct insertion sort, length of the array to sort records in the number of
{
int i,j;
For (I=2; i<=length; I++)
{
R [0]=r [I];
J=I - 1;
While (r [0]. Key{
R=r [m + 1] [j];
J=j - 1;
}
R=r [0] [j + 1];
}
}
Void main ()
{
Int length, I;
Recordtype r;
//enter
For (I=0; I & lt; Length; I++)
{
The scanf (" % d ", & amp; R [I]);
}
printf("\n");
Inssort (r, length);
//output
For (I=0; I & lt; Length; I++) {
Printf (" % d ", "r" [I]);
}
printf("\n");
} where is wrong
  • Related