Home > Back-end >  Everyone a great god can help us see, array to read, don't get so touching layout as far as pos
Everyone a great god can help us see, array to read, don't get so touching layout as far as pos

Time:09-18

# include & lt; stdio.h>
20 # define N
# define the ERROR 0
# define OK 1
Typedef int ElemType;//linear table data element type type redefine
Typedef struct {
ElemType * elem;//store data element array int length;
} SeqList;//the structure type of the linear table table//o long int ListLength SeqList (L) {
Return L.l ength;
}
//insert element int InsertElem (SeqList * L) {
int i,j;
ElemType e;
If (i<=0 | | i> L - & gt; Length + 1) {
Return the ERROR;
}
If (L - & gt; length>=N) {
Return the ERROR;
}
For (j=L - & gt; Length - 1. J>=I - 1; J -) {
L - & gt; Elem [j + 1)=L - & gt; Elem [j];
} L - & gt; Elem] [I - 1=e;
L - & gt; length++;
return OK;
}
Void PrintList (SeqList L)//print table
{
int i; Printf (" the length of the table is: % d \ n ", L.l ength); Printf (" this table for each element: \ n ");
for(i=0; I<=L.l ength - 1; I++)
{
Printf (" % d \ t ", L.e lem [I]); } printf (" \ n ");
}
Void SelectSort (SeqList * L)//simple selection sort {
Int I, j, k;
for(i=1; I<=L - & gt; Length - 1. I++)
{
K=1;
For (j=I + 1; J<=L - & gt; Length; J++)
If (L - & gt; Elem [j] K=j;
If (k!=I)
{L - & gt; Elem [0] L - & gt; Elem [I] L - & gt; Elem [k] }
}
}
Int main () {
SeqList L;
ElemType elem [9]=,49,38,65,97,76,13,27,49 {0}; int i;
//InitList (& amp; L);
InsertElem (& amp; L);
for(i=1; I<=9; I++) {
//InitList (& amp; L);
InsertElem (& amp; L);
Printf (" \ n simple selection sort before ");
PrintList (L);
SelectSort (& amp; L);
Printf (" \ n \ n \ n after direct insertion sort "); PrintList (L); }}

CodePudding user response:

So moving,,,

CodePudding user response:

O.k., should be able to see it
  • Related