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

Time:12-08

#include
# define list_size 20
Typedef int keytype;
Typedef int othertype;
Typedef struct
{
Keytype key;
Othertype other_data;
} recordtype;
Void the display (recordtype r [], int length)
{
for (int i=0; i Printf (" % d ", "r" [I]);
}
printf("\n");
}
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 ()
{

}
How to write a main function

CodePudding user response:

 # include 

# define list_size 20

Typedef int keytype;
Typedef int othertype;

Typedef struct
{
Keytype key;
Othertype other_data;
} recordtype;

Void the display (recordtype r [], int length)
{
for (int i=0; i Printf (" % d ", "r" [I] key);
}
printf("\n");
}

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 main (void)
{
Recordtype r [list_size];




return 0;
}

For your reference ~
  • Related