# Include <stdio. h>
# Include <malloc. h>
# Define N 10
Typedef struct Node
{
Char name [20];
Struct node * llink, * rlink;
} Stud;
Stud * creat (int n)
{
Stud * P, * H, * s;
Int I;
If (H = (stud *) malloc (sizeof (stud) = NULL)
{
Printf ("memory cannot be allocated! ");
Exit (0 );
}
H-> name [0] = '\ 0 ';
H-> llink = NULL;
H-> rlink = NULL;
P = h;
For (I = 0; I <n; I ++)
{
If (S = (stud *) malloc (sizeof (stud) = NULL)
{
Printf ("memory cannot be allocated! ");
Exit (0 );
}
P-> rlink = s;
Printf ("Enter the personal name of % d", I + 1 );
Scanf ("% s", S-> name );
S-> llink = P;
S-> rlink = NULL;
P = s;
}
H-> llink = s;
P-> rlink = h;
Return (h );
}
Stud * search (stud * H, char * X)
{
Stud * P;
Char * Y;
P = H-> rlink;
While (P! = H)
{
Y = p-> name;
If (strcmp (Y, x) = 0)
Return (P );
Else P = p-> rlink;
}
Printf ("this data is not found! ");
}
Void print (stud * H)
{
Int N;
Stud * P;
P = H-> rlink;
Printf ("data information: \ n ");
While (P! = H)
{
Printf ("% s", & * (p-> name ));
P = p-> rlink;
}
Printf ("\ n ");
}
Void main ()
{
Int number;
Char studname [20];
Stud * head, * searchpoint;
Number = N;
Clrscr ();
Head = creat (number );
Print (head );
Printf ("enter the name of the person you want to search :");
Scanf ("% s", studname );
Searchpoint = search (Head, studname );
Printf ("the name of the person you want to search for is: % s", * & searchpoint-> name );
}