dear bosses, I list the last function, is to put a singly linked list is divided into odd and even function of black outage window, I feel like I write is right ah, why odd and even table can't display, bosses, please indicate the [/colo] /* # include & lt; Iostream. H>
#include */
#include
#include
#include
#include
#include
#include
//define the type of node
Struct Node {//definition structure (nodes) data type, a name, called Node
int data;
Node * next;
};
The Node Head, ha, hb, hc;//head node
DLList Node * and * a * b * c.//the head pointer//this two paragraphs are declare custom data types Node
Void init (Node * DLList);
Void the display (Node * DLList);
Int the insert (Node * DLList);
Void search (Node * DLList);
Void del (Node * DLList);
Void reverse (Node * DLList);//on the inverse set function
Void sort (Node * DLList);//orderly insertion sort function
Void generateandmerge (Node * a, Node * b, Node * c);//generated two chain table and merge function
Void devide (Node * DLList, Node * a, Node * b);//a table can be divided into odd and even number two tables, ordering the same
Int main ()
{
Char choice;
A=& amp; Ha.
B=& amp; Hb.
C=& amp; Hc.//is the bosses remind before without the pointer to the first three pointer, so much so that the three pointer as wild pointer
DLList=& amp; The Head;//make the head pointer to head node
Head. Next=NULL;
Ha. Next=NULL;
Hb. Next=NULL;
Hc. Next=NULL;
While (1)
{
//system (" CLS ");
Printf (" \ n \ n \ n \ n ");
Printf (" \ t \ \ t singly linked lists operation n ");
Printf (" \ \ t t======================================");
Printf (" \ n \ n ");
Printf (" \ \ t t 1: initialize \ n ");
Printf (" \ \ t t 2: displays \ n ");
Printf (" \ \ t t 3: a single insert \ n ");
Printf (" \ \ t t 4: find \ n ");
Printf (" \ t \ t 5: delete \ n ");
Printf (" \ t \ t 6: in situ inverse set \ n ");
Printf (" \ t \ t 7: orderly insertion sort \ n ");
Printf (" \ t \ t 8: generates two list and merge \ n ");
Printf (" \ t \ t 9: will a list generated odd, even two list \ n ");
Printf (" \ t \ t 0: exit \ n ");
Printf (" \ n ");
Printf (" \ t \ t please select: ");
Choice=getch ();
//system (" CLS ");
The switch (choice)
{
Case '1' :
Init (DLList);
break;
Case '2' :
The display (DLList);
break;
Case '3' :
Insert (DLList);
break;
Case '4' :
Search (DLList);
break;
Case '5' :
Del (DLList);
break;
Case '6' :
Reverse (DLList);
break;
Case '7' :
Sort (DLList);
break;
Case '8' :
Generateandmerge (a, b, c);
Case '9' :
Devide (DLList, a, b);
break;
Case '0' :
exit(0);
}
}
}
//public wait functions
Void wait ()
{
Printf (" \ n \ n press any key to continue ");
Getch ();
}
//screen, input from the keyboard linear table length and the random number seed, generate the DLList as head pointer specified length linear table
Void init (Node * DLList)//implement the establishment of a singly linked list
{
Int length;
The Node * p, * q;
While (1)
{
Printf (" input element number (0-10000) : ");
The scanf (" % d ", & amp; Length);
If (length & gt;=0 & amp; & Length & lt;
=10000)break;
printf("\n");
}
int i;
While (1)
{
Printf (" input random number seed (0-32767) : ");
The scanf (" % d ", & amp; I);
If (I & gt;=0 & amp; & I & lt;
=32767)break;
printf("\n");
}
//delete from the linear table and release the original node, making it a empty table
P=DLList;
While (p - & gt; Next!=NULL)
{
Q=p - & gt; Next;
P - & gt; Next=q - & gt; Next;
Free (q);
}
Srand (I);//the specified random number seed, the seeds of the same will produce the same data sequence
The rand ();
//insert length to the linear table a new node
For (int j=1; j<=length; J++)
{
P=new Node;
P - & gt; Next=DLList - & gt; Next;
DLList - & gt; Next=p;
P - & gt; data=https://bbs.csdn.net/topics/rand () % 10000;
}
}
//in turn display on the screen for DLList head pointer all the elements and the number of elements of the linear table
//format should be easy to observe
//if you need to specify the width of the output, you can use the cout & lt; Void the display (Node * DLList)
{
//the Node * DLList;
//DLList=head; It has already been defined, defines redefine mistake will happen again here,
If (DLList==NULL)
{
Printf (" list is empty!" );
}
While (DLList)
{
Printf (" % d ", DLList - & gt; The data);
DLList=DLList - & gt; Next;
}
printf("\n");
Printf (" list finished output \ n ");
}
//screen prompts, an element from the keyboard input value, and then insert the new element to the DLList as head pointer at the end of the linear table!!
Int the insert (Node * DLList)
{int num.
Node * temp;
Printf (" please input a need to insert the element value: ");
The scanf (" % d ", & amp; Num);
If (NULL==DLList)
{
return 1;
}
//create a new node and determine whether to create success
Node * Node=(*) malloc (sizeof (Node)/sizeof (char));
If (NULL==node)
{
return 0;
}
//to node member variable assignment
Node - & gt; Data=https://bbs.csdn.net/topics/num;
Node - & gt; Next=NULL;
//the new node into the list of the last node
Node * TMP=DLList;
While (TMP - & gt; Next)
{
TMP=TMP - & gt; Next;
}
//find the list of end node and end node to node
TMP - & gt; Next=node;
While (DLList)
{
Printf (" % d ", DLList - & gt; The data);
DLList=DLList - & gt; Next;
}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull