Home > Back-end >  The data structure
The data structure

Time:10-08

I really can't write here! Save me

CodePudding user response:

You can consult the pseudo code you write,
Values: int GetElem (SqList L, int I ElemType & amp; E)//reference e in the main function can fix change
{
If (I & lt; 1 | | I & gt; L.l ength)//whether the number in the table, then the embodiment of the algorithm robustness,
{
return 0;
}
E=L.e lem {I - 1);//position than the subscript 1, I was I - 1 is corresponding to the location of the subscript
Return 1;
}
//insert int InsertList (SqList & amp; L, int I ElemType e)
{
If (I & lt; 1 | | I & gt; L.l ength + 1)//when the order form for immediate predecessor and immediate successor, so most elements can only be inserted after the last element of a position
{
return 0;
}
If (L.l ength & gt;=L.l isisize)//L.l isisize table the maximum capacity of the said order
{
ElemType * newbase=(ElemType *) realloc (L.e lem, (L.l isisize + 10) * sizeof (ElemType));//space is not enough to apply for space
if(! Newbase)
{
return 0;
}
L.e lem=newbase;
L.l isisize +=10;
}
ElemType * p * q;
Q=& amp; L.e lem [I - 1);
For (p=& amp; L.e lem [L.l NGTH - 1); P & gt;=q; P -)
{
* (p + 1)=* p;
}
* q=e;
L.l ength + +;
Return 1;

}

CodePudding user response:

To write not to come out, also can write a wrong, what can not try how can anyone know?

CodePudding user response:

Write not to come out is the theoretical basis is not enough, go back to look at the order sheet is a something, and then write
After all procedures are in accordance with your idea to implement the code
This must be resolved first
Otherwise, others will give you the code, will cope with homework, or a bit not
See other people's code, really tired, than to write their own thinking is different, everyone look at the others will go to understand the ideas of others, don't know, see more confused

Support on the second floor said, write their own

CodePudding user response:

refer to 1st floor @ big fool @ reply:
you can consult the pseudo code you write,
Values: int GetElem (SqList L, int I ElemType & amp; E)//reference e in the main function can fix change
{
If (I & lt; 1 | | I & gt; L.l ength)//whether the number in the table, then the embodiment of the algorithm robustness,
{
return 0;
}
E=L.e lem {I - 1);//position than the subscript 1, I was I - 1 is corresponding to the location of the subscript
Return 1;
}
//insert int InsertList (SqList & amp; L, int I ElemType e)
{
If (I & lt; 1 | | I & gt; L.l ength + 1)//when the order form for immediate predecessor and immediate successor, so most elements can only be inserted after the last element of a position
{
return 0;
}
If (L.l ength & gt;=L.l isisize)//L.l isisize table the maximum capacity of the said order
{
ElemType * newbase=(ElemType *) realloc (L.e lem, (L.l isisize + 10) * sizeof (ElemType));//space is not enough to apply for space
if(! Newbase)
{
return 0;
}
L.e lem=newbase;
L.l isisize +=10;
}
ElemType * p * q;
Q=& amp; L.e lem [I - 1);
For (p=& amp; L.e lem [L.l NGTH - 1); P & gt;=q; P -)
{
* (p + 1)=* p;
}
* q=e;
L.l ength + +;
Return 1;

}

Thank you thank you yesterday, I have to hand in

CodePudding user response:

reference 2 building self-confidence boy reply:
to write not to come out, also can write a wrong, what can not try how can anyone know?

I have to hand in, thank you?

CodePudding user response:

Fun
reference 3 floor response:
write not to come out is the theoretical basis is not enough, go back to look at the order sheet is a something, and then write
After all procedures are in accordance with your idea to implement the code
This must be resolved first
Otherwise, others will give you the code, will cope with homework, or a bit not
See other people's code, really tired, than to write their own thinking is different, everyone look at the others will go to understand the ideas of others, don't know, see more confused

Support said on the second floor, write their own

Yesterday, I have already written out your I will listen to your advice, thank you
  • Related