I want to use structure inserted the 5 into the 1234678 array, what is wrong? Who help me ah, don't passed the
#include
# define maxsize 100
Typedef struct
{
The int data [maxsize];
int length;
} Sqlist;
,2,3,4,6,7,8 Sqlist L={{1}, 8};
Int findelem (Sqlist L, int x);
Void insertelem (Sqlist & amp; L, int x);
Int main (void)
{
Insertelem (L, 5);
Int j=0;
While (j & lt; L.l ength - 1) {
Printf (" % d ", L.d ata [maxsize]);
J++;
}
return 0;
}
Int findelem (Sqlist L, int x)//find position
{
int i;
For (I=0; I & lt; L.l ength; + + I)
{
If (x & lt; L.d ata [I])
{
return i;
}
}
return i;
}
Void insertelem (Sqlist & amp; L, int x)//insert
{
Int I, p;
P=findelem (L, x);
For (I=L.l ength - 1; I & gt;=p; - I)
L.d ata [I + 1)=L.d ata [I];
L.d ata [p]=x;
+ + L.l ength;
}
CodePudding user response:
Modify the followingWhile (j
J++;
}