Home > other >  Simple application list field for the great spirit
Simple application list field for the great spirit

Time:10-16

#include
#include
# define OK 1
# define the ERROR 0
Typedef int Elemtype;
Typedef int the Status;
Static int length=0;
Typedef struct ListNode {
Elemtype data;
Struct ListNOde * next;
} Node, * Pnode;

The Status build_ListNode (Pnode& The head, int circle) {
Pnode p;
for (int i=0; i If (head=='\ 0') {
if (! (Pnode) malloc (sizeof (struct ListNode))) {
Printf (" % d nodes to create failure \ n ", I + 1);
Return the ERROR;
}
The else
{
The head=(Pnode) malloc (sizeof (struct ListNode));
P=the head;
P - & gt; Next='\ 0';
Length++;
The scanf (" % d ", & amp; P - & gt; The data);
}
}
The else {
if (! (Pnode) malloc (sizeof (struct ListNode))) {
Printf (" % d nodes to create failure \ n ", I + 1);
Return the ERROR;
}
The else {
If (I & gt;=2) {
P=p - & gt; next;
}
Pnode r=(Pnode) malloc (sizeof (struct ListNode));
P - & gt; Next=r;
R - & gt; Next='\ 0';
Length++;
The scanf (" % d ", & amp; R - & gt; The data);
}
}
}
return OK;
}

The Status insert_ListNode (Pnode& The head, int pos, Elemtype value) {
If (pos<0 | | pos> Length) {
Printf (" insert position illegal \ n ");
Return the ERROR;
}
The else {
Pnode r, p;
P=the head;
for (int i=0; i P=p - & gt; next;
}
R=(Pnode) malloc (sizeof (struct ListNode));
If (pos==0) {
R - & gt; Next=p;
The head=r;
}
The else {
R - & gt; Next=p - & gt; next;
P - & gt; Next=r;
R - & gt; Data=https://bbs.csdn.net/topics/value;
}
return OK;
}
}

Void fuction_Selection () {
Pnode head;
Build_ListNode (head, 10);
Insert_ListNode (head, 5, 10);
}
Int main () {
Fuction_Selection ();
return 0;
}

Why there will be a great god explain such a mistake
  • Related