#include
using namespace std;
Template
The class Singlenode
{
Public:
T data;//data domain
Singlenode
Singlenode blank nodes ()//construction, but not initialized data domain
{
This - & gt; next=NULL;
}
Singlenode (T data, Singlenode
{this - & gt; data=https://bbs.csdn.net/topics/data;
This - & gt; Next=next;
}
};
The CPP file:
//write classes and member function, the realization of input a group of elements to build a leading the singly linked list of nodes; The list is not descending order;
//delete the values in the decreasing order list for the node of x;
#include
# include "Singlenode1. H"
using namespace std;
Template
Class Singlelinklist//create a singly linked list class
{public:
Singlenode
Singlelinklist ();//structure empty table
Singlelinklist (int value [], int n);//structure singly linked list
~ Singlelinklist ();
Boolean isempty ();//to empty
Int getlength (); Length//o
Void the sort ();//order
Void deleteelem (int);//delete specific element
Void clearlist ();//to empty list
Void the display ();
};
Template
Singlelinklist
{this - & gt; The head=NULL;
}
Template
Singlelinklist
{the head=NULL;
If (n> 0)
{
The head=new Singlenode
Singlenode
Int I=1;
while(i
Rear - & gt; Next=new Singlenode
Rear=rear - & gt; next;
}
}
}
Template
Singlelinklist
{clearlist ();
}
Template
Bool Singlelinklist
{return head==NULL;
}
Template
Void Singlelinklist
{Singlenode
While (p)
{
Singlenode
p=p-> next;
delete q;
}
The head=NULL;
}
Template
Int Singlelinklist
{Singlenode
Int I=0;
while(p!=NULL) {
p=p-> next;
i++;
}
Return the I;
}
Template
Void Singlelinklist
{Singlenode
int t;
Singlenode
for(; p; p=p-> Next) {
For (q=p - & gt; next; q; Q=q - & gt; Next)
{if (q - & gt; Data
T=p - & gt; The data, p - & gt; data=https://bbs.csdn.net/topics/q-> data, q -> data=t;
}
}}
Template
Void Singlelinklist
{Singlenode
Singlenode
while(p!=NULL) {
If (p - & gt; data=https://bbs.csdn.net/topics/=x) {
Q=p; p=p-> next; delete q;
} the else p=p - & gt; next; }
}
Template
Void Singlelinklist
Singlenode
for(; p; p=p-> Next) {
Cout
}
Cout
Int main () {
Int n, x;
The int value [100].
Cout<& lt;" Please enter the number list elements: "& lt;
Cout<& lt;" Please input the list element in turn: "& lt;
}
Singlelinklist
If (T1) isempty ()) {
Cout<& lt;" The list is empty! End of the program!"
Cout<& lt;" List of length: "& lt;
Cout<& lt;" Order list is: "& lt;
Cout<& lt;" Please input value to delete, and we will delete all of equal value, "& lt;
T1. Deleteelem (x);
Cout<& lt;" List as follows: "& lt;
T1. ~ Singlelinklist ();
return 0;
}
Then access conflict:
Displays an error of 0 XDDDDDDDD
And made a night really couldn't move I was a child, why the code is so cruel