Home > Back-end >  Where is wrong?
Where is wrong?

Time:10-22

#include using namespace std; # define Initsize 100 typedef int ElemType; Typedef struct {ElemType * data; Int MaxSize length; } seqList; Void Init (seqList * L) {L - & gt; data=https://bbs.csdn.net/topics/(ElemType *) malloc (sizeof (ElemType) * Initsize); L -> length=0; L -> MaxSize=Initsize; } to void the create (seqList * L, int n) {int I; for (i=0; i (L -> data [I]); L -> length=n; }} to void the show (seqList L) {int I; for(i=0; i data [0]; Int pos=0, I; for(i=1; I <-> L length; I++) {if (L -> data [I] value) <* {* value=L -> data [I]; Pos=I; }} L -> data (pos)=L -> data [L -> length - 1]. L -> length -; return true; } int main () {int n, the value; SeqList L; Init (& L); Cin> n. Create (& L, n); Del_Min (& L, & value); Show (L); cout CodePudding user response:

 
#include
using namespace std;
# define Initsize 100
typedef int ElemType;
Typedef struct {
ElemType * data;
Int MaxSize length;
} seqList;
Void Init (seqList * L)
{
L - & gt; Data=(ElemType * https://bbs.csdn.net/topics/malloc (sizeof (ElemType) * Initsize);
L - & gt; Length=0;
L - & gt; MaxSize=Initsize;
}
Void the create (seqList * L, int n)
{
int i;
For (I=0; I & lt; n; I++)
{
Cin & gt;> (L - & gt; Data [I]);
L - & gt; Length=n;
}
}
Void show (seqList L)
{
int i;
For (I=0; I & lt; L.l ength; I++)
{
cout }
}
Bool Del_Min (seqList * L, ElemType * value)
{
If (L - & gt; Length==0)
{
return false;
}
* value=https://bbs.csdn.net/topics/L-> data [0];
Int pos=0, I;
for (i=1; I & lt; L - & gt; Length; I++)
{
If (L - & gt; Data [I] <* value)
{
* value=https://bbs.csdn.net/topics/L-> data [I];
Pos=I;
}
}
L - & gt; Data (pos)=L - & gt; Data] [L - & gt; length - 1.
L - & gt; Length -;
return true;
}
Int main ()
{
Int n, the value;
SeqList L;
Init (& amp; L);
Cin & gt;> n;
Create (& amp; L, n);
Del_Min (& amp; L, & amp; value);
Show (L);
cout return 0;
}

No problem, you can remove a minimum value,

CodePudding user response:

You somehow smoothing out the code to give a person look
  • Related