Home > Back-end > Bosses give directions, data structures and algorithms
Bosses give directions, data structures and algorithms
Time:10-21
CodePudding user response:
Void insertList (DLNode * p, ElementType x) { If (NULL==p) return; DLNode * pT=(DLNode *) malloc (sizeof (DLNode)); PT - & gt; Data=https://bbs.csdn.net/topics/x; PT - & gt; The prior=p - & gt; The prior; PT - & gt; Next=p; P - & gt; The prior=pT; }
CodePudding user response:
void insertList (DLNode * p, ElementType x) { If (NULL==p) return; DLNode * pT=(DLNode *) malloc (sizeof (DLNode)); if (! PT) return NULL; PT - & gt; Data=https://bbs.csdn.net/topics/x; PT - & gt; The prior=p - & gt; The prior; PT - & gt; Next=p; P - & gt; The prior=pT; }
Add 1 to pT application space after judgment, In addition, there is a problem in this function, if p is the first node, then the function can also can? P needs to be considered is the location of the head or middle, or end,