Home > Back-end >  The list
The list

Time:10-07

The code for this
Bosses to fly with the
Linked list node insert

CodePudding user response:

Typedef struct _stuList
{
_stuList * pNext;
Int nNode;
} stuList;

Int nArray=0;
While (nArray & lt;=0)
{
Printf (" please input to input the number of groups: \ n ");
The scanf (" % d ", & amp; NArray);
}

Int * arrayM=(int *) malloc (sizeof (int) * nArray);
Int * arrayX=(int *) malloc (sizeof (int) * nArray);
for(int i=0; i{
The scanf (" % d % d ", & amp; ArrayM [I], & amp; ArrayX [I]);
}

StuList * pHead=(stuList *) malloc (sizeof (stuList));
PHead - & gt; PNext=NULL;
PHead - & gt; NNode=1;

StuList * pData=https://bbs.csdn.net/topics/NULL;
PPoint stuList *=NULL;

for (int i=0; i{
PData=https://bbs.csdn.net/topics/(stuList *) malloc (sizeof (stuList));
PData - & gt; PNext=NULL;
PData - & gt; NNode=arrayX [I];

Int nMi=arrayM [I];
PPoint=pHead;
While (pPoint - & gt; PNext!=NULL & amp; & NMi> 0)
{
- nMi;
PPoint=pPoint - & gt; PNext;
}

PData - & gt; PNext=pPoint - & gt; PNext;
PPoint - & gt; PNext=pData;
}

PData=https://bbs.csdn.net/topics/pHead-> pNext;
While (pData!=NULL)
{
Printf (" % d ", pData - & gt; NNode);
PData=https://bbs.csdn.net/topics/pData-> pNext;
}
printf("\n");


While (pHead!=NULL)
{
PData=https://bbs.csdn.net/topics/pHead;
PHead=pHead - & gt; PNext;
Free (pData);
}
Free (arrayM);
Free (arrayX);
  • Related