Home > Back-end >  C language data structure problems of interpolation
C language data structure problems of interpolation

Time:10-01

#include
#include

# define NULL 0
# define OK 1

Typedef char ElemType;
Typedef struct Node
{
Char data;
Struct Node * next;
} the Node;
Typedef struct Node * LinkList;

Int ListInsert1 (LinkList * L)
{
LinkList p;
P=(LinkList) malloc (sizeof (Node));
P - & gt; Next=NULL;
P - & gt; data=https://bbs.csdn.net/topics/NULL;
Printf (" create an empty list success: \ n ");
Return OK;
}

Int ListInsert (LinkList * L)
{
ElemType x;
LinkList s, r=NULL;
The scanf (" % d ", & amp; X);
While (x!=1)
{
S=(LinkList) malloc (sizeof (Node));
S - & gt; data=https://bbs.csdn.net/topics/x;
If (L==NULL)
* L=s;
The else
R - & gt; Next=s;
R=s;
The scanf (" % d ", & amp; X);
}
If (r!=NULL)
R - & gt; Next=NULL;
return 1;
}

/* int DispList (LinkList * L)
{
LinkList p;
For (p=* L; P; P=p - & gt; Next)
Printf (" % d ", p - & gt; The data);
printf("\n");
return 1;
}

Int ListLength (LinkList * L)
{
LinkList p;
Int length=0;
P=* L;
While (p!=NULL)
{
P=p - & gt; next;
Length++;
}
Printf (" % d \ n ", length);
return 1;
} */

Void main ()
{
LinkList L;
Printf (" initialization singly linked lists L; \n");
ListInsert1 (& amp; L);
Printf (" insert element in turn ");
ListInsert (& amp; L);
/* printf (" output singly linked list: ");
DispList (& amp; L);
Printf (" output singly linked lists the length of L: ");
ListLength (& amp; L); */
}

  • Related