#include
using namespace std;
# define OK 1
# define the ERROR 0
# define ElemType int
Typedef int the Status;
Typedef struct LNode
{
ElemType data;
Struct LNode * next;
} LNode * LinkList;
//create a singly linked list
LNode * creat ()
{
LNode * head, * p;
The head=new LNode;
P=the head;
Int x, cycle=1;
While (cycle)
{
Cout & lt; <"Both Please input the data for single would:";
Cin & gt;> x;
If (x!=0)
{
LNode * s=new LNode;
S - & gt; Data=https://bbs.csdn.net/topics/x;
Cout & lt; <"Input data:" & lt;
P=s;
}
The else
{
Cycle=0;
Cout & lt; <"Input done! "& lt;
}
P - & gt; Next=NULL;
//cout & lt; <"\ nFirst data of single would is" & lt;
return head;
}
//print singly linked list
Void printL (LNode * head)
{
LNode * p=head;
P=p - & gt; next;
while (p !=NULL)
{
Cout & lt; <"Single would data is" & lt; P=p - & gt; next;
}
}
//singly linked lists measuring
Int length (LNode * head)
{
int n=0;
LNode * p=head;
While (p - & gt; Next!=NULL)
{
P=p - & gt; next;
n++;
}
return n;
}
Void del_nolmal (LNode * head)
{
LNode * head1=head;
LNode * p=head1 - & gt; next;
int i;
Int len=length (head1);
Int Max=p - & gt; The data;
Int min=p - & gt; The data;
For (I=0; I & lt; len; I++)
{
P=p - & gt; next;
If (p!=NULL)
{
If (p - & gt; The data & gt; Max)
{
Max=p - & gt; The data;
}
}
}
P=head1;
For (I=0; I & lt; len; I++)
{
P=p - & gt; next;
If (p!=NULL)
{
If (p - & gt; The data & lt; Min)
{
Min=p - & gt; The data;
}
}
}
P=head1;
For (I=0; I & lt;=len; I++)
{
LNode * q=p - & gt; next; A data element before/record/p4 p3
If (q!=NULL)
{
If ((q - & gt; Data
If (q - & gt; Next!=NULL)
{
P - & gt; Next=q - & gt; next;
}
The else
{
P - & gt; Next=NULL;
}
}
}
Free (p);
}
Int main ()
{
Cout & lt; <"To create a single table * * * * * *" & lt;
Cout & lt;
Cout & lt; <"* * * * * * print singly linked lists" & lt;
Cout & lt;
Printf (" len=% d ", length (the head));
Del_nolmal (head);
Cout & lt;
Cout & lt; <"* * * * * * print singly linked lists" & lt;
Cout & lt;
CodePudding user response:
S - & gt; Data=https://bbs.csdn.net/topics/x;Cout & lt; <"Input data:" & lt;
P=s;
Here the wrong
CodePudding user response:
The