# include
# include
# include
# include
using namespace std;
Typedef struct node
{
The int data;
Node * next;
} the node;
Node * creat ()
{
The head=new node, the node * * p=new node, * s * q;
S=the head;
Int m;
for(int i=0; m!=0; I++)
{
Cin> m;
S - & gt; data=https://bbs.csdn.net/topics/m;
Q - & gt; Next=s;
The head=q;
S=p;
}
Cout
* the output node (the node * head)
{
While (the head!=NULL)
{
Cout
}
Cout
The node * insert (node * head, int, int x)
{
Node * p=head;
Int k=0;
If (i<1)
Cout<" There is no the first "& lt; The else
{
While (p!=NULL& & K{
P=p - & gt; next;
K++;
}
If (p=NULL)
Cout<" Beyond the list can be inserted into the largest position!"
{
Node * q=new node;
Q - & gt; data=https://bbs.csdn.net/topics/x;
Q - & gt; Next=p - & gt; next;
P - & gt; Next=q;
}
}
}
Node * del (node * head, int I)
{
Node * p=head;
Node * q;
Int k=0;
If (i<1)
Cout<" There is no the first "& lt; The else
{
While (p!=NULL& & K{
Q=p;
P=p - & gt; next;
K++;
}
If (p=NULL)
Cout<" Beyond the chain length of the table!"
{
Q - & gt; Next=p - & gt; next;
The delete p;
The node * m=head - & gt; next;
While (m!=NULL)
Cout
}
}
Node * search (node * head, int x)
{
The node * p=head - & gt; next;
While (p!=NULL& & P - & gt; The data!=x)
P=p - & gt; next;
If (p=NULL)
Cout<" To find the failure!"
{
Return the p;
}
}
Int main ()
{
Int I, x, j, k;
The head node *=new node;
Cout<" . Create a singly linked list... "& lt;
The output node * (the head);
Cout<" In the case of a node I insert a value for the node of x "& lt;
Cout<" Input the value of x \ n: "& lt;
The head=insert (head, I, x);
Cout<" Delete the first j a node, and then in turn shows a singly linked list after deleting data elements "& lt;
The head=del (head, j);
Cout<" To find out the value of k in the node "& lt;
The node * d=search (head, k);
Cout
}
CodePudding user response:
First learn to debug,