Home > Back-end >  Chain table access conflict
Chain table access conflict

Time:11-29

 # include & lt; iostream> 
#include
#include
using namespace std;
Typedef struct sl
{
string name;//school name
String prov.//in which province
The string type.//category
Double value=https://bbs.csdn.net/topics/0;//score
}
DataType.
String ze.
Struct Node
{
DataType SCH.
Next Node *=NULL;
};
The class LinkList
{
Private:
Int curlen;
Head Node * and * p, * temp;
Public:
LinkList ()
{
Temp=NULL;
The head=new Node;
The head - & gt; Next=NULL;
P=the head;
Curlen=0;
}
LinkList Delete (double x)
{
LinkList re;
Sl sc1.
Prev=head Node * and * TMP=nullptr;
While (prev - & gt; Next!=nullptr)
{
TMP=prev - & gt; Next;
If (TMP!=nullptr & amp; & TMP - & gt; SCH. Value & lt; X)
{
Sc1. Name=TMP - & gt; SCH. Name;
Sc1. Prov=TMP - & gt; SCH. Prov;
Sc1. Type=TMP - & gt; SCH. Type;
Sc1. Value=https://bbs.csdn.net/topics/tmp-> SCH. Value;
Re. Insert (sc1);
Prev - & gt; Next=TMP - & gt; Next;
Curlen -;
Delete the TMP;
}
The else
Prev=prev - & gt; Next;
}
Return re;
}
Bool Insert (DataType x)
{
Node * temp=new Node;
Temp - & gt; SCH. Name=x.n ame;
Temp - & gt; SCH. Prov=x.p the rov;
Temp - & gt; SCH. Type=x.t ype;
Temp - & gt; SCH. Value=https://bbs.csdn.net/topics/x.value;
Temp - & gt; Next=nullptr;
P - & gt; Next=temp;
P=temp.
Curlen++;
return true;
Void the Display (string x)
{
Node * teb;
The teb=head - & gt; Next;
While (teb!=NULL)
{
If (teb - & gt; SCH. Type==x)
Cout & lt; The teb=teb - & gt; Next;
}
Cout & lt; <"\ n";
}
~ LinkList ()
{
Pre=head Node * and * x=head - & gt; Next;
While (x!=NULL)
{
Delete the pre.
The pre=x;
X=pre - & gt; Next;
}
The delete p, temp, head;
}
};
Int main ()
{
LinkList school1, sc2;
DataType test;
String a;
double d;
Cout & lt; <"Read a number from the keyboard, the score is less than the value of the school is extracted from the list (delete) in the original table, table and put these block to build a new order \ n";
Cin & gt;> d;//input a number
Cout & lt; <"Please enter a category" & lt; <"\ n";
Cin & gt;> a;//enter a category (general or polytechnic)
Sc2=school1. Delete (d);
Cout & lt; <"Less than" & lt; Sc2. The Display (a);
Cout & lt; <"More than" & lt; School1. The Display (a);
system("pause");
}



As title after enter the scores and categories will produce access conflict, want to please the great god and see what is the problem of this code, the beginners, level is not high, modestly consult!!!!!
Should be below normal circumstance left

  • Related