Home > Back-end >  Singly linked lists code to run is not the operation, the teacher said a Trojan, or a file is outsou
Singly linked lists code to run is not the operation, the teacher said a Trojan, or a file is outsou

Time:09-24

Don't know where the singly linked list operation code has a problem, also don't know how to correct, please help:
# 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)
{
CoutThe head=head - & gt; next;
}
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!" The else
{
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!" The else
{
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!" The else
{
Return the p;
}
}
Int main ()
{
Int I, x, j, k;
The head node *=new node;

Cout<" . Create a singly linked list... "& lt; Creat ();
The output node * (the head);


Cout<" In the case of a node I insert a value for the node of x "& lt; Cout<" The value of the input I: \ n "& lt; Cin> i;
Cout<" Input the value of x \ n: "& lt; Cin> x;
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; Cout<" Input j: "& lt; Cin> j;
The head=del (head, j);


Cout<" To find out the value of k in the node "& lt; Cin> k;
The node * d=search (head, k);
Cout
}

CodePudding user response:

First learn to debug,
  • Related