Link list list.h

xiaoxiao2021-03-06  94

///

///

/ / Link list list.h //

///

//

#include "list.h"

#include

#include

Template

Void Initlist (Type & TMP)

{

List list;

Int n;

While (True)

{

Cout << "Please select the action you want to do with the list" << Endl

<< "1) Insert data at the end" << ENDL

<< "2) Insert data at any place << ENDL

<< "3) Delete Data Item" << ENDL

<< "4) Delete the entire list" << ENDL

<< "5) Print Next table" << ENDL

<< "6) Find data item" << ENDL

<< "7) Exit" << Endl;

COUT << "> /";

CIN >> N;

While (n <1 || n> 7)

{

Cout << "Enter is incorrect, please enter from the new input!" << Endl;

COUT << "> /";

CIN >> N;

}

Switch (n)

{

Case 1: list_insertend (list); Break;

Case 2: list_INSERT (LIST); Break;

Case 3: List_Delnode (list); Break;

Case 4: List_makeempty (list); Break

Case 5: List_print (list); Break;

Case 6: List_find (list); Break;

Case 7: Return; Break;

}

}

}

void list ()

{

Int n;

Cout << "Please select the data type 1 of the list you want to construct 1) integer, 2) character type, 3) floating point" << end1

COUT << "> /";

CIN >> N;

While (n <1 || n> 3)

{

Cout << "Enter is incorrect, please enter from the new input!" << Endl;

COUT << "> /";

CIN >> N;

}

CHAR T_C = 'C';

INT T_I = 12;

Double T_F = 23.3;

Switch (n)

{

Case 1: Initlist (T_i); Break;

Case 2: InitList (T_C); Break;

Case 3: InitList (T_F); Break;

}

}

Template

Void List_insertend (List & l)

{

TYPE T;

COUT << "Please enter the insert data:> /";

CIN >> T;

L. INSERTEND (T);

}

Template

Void List_Find (List & l)

{

TYPE T;

Cout << "Please enter the data item you want to find:> /"; cin >> T;

INT I;

IF (! (i = l.find (t))))))

Cout << "The data item you want to find does not exist!" << Endl;

Else

Cout << "The data item you want to find is in the" << i << "<<" << ENDL;

}

Template

Void List_Insert (List & l)

{

TYPE T;

COUT << "Please enter the insert data:> /";

CIN >> T;

Int n;

Cout << "Please enter the insert location:> /";

CIN >> N;

IF (L.Insert (t, n)))

Cout << "Insert success! In" << n << "position insert" << t << endl;

Else

Cout << "Insert Failed! Inserting position is incorrect!" << Endl;

}

Template

Void List_Delnode (List & l)

{

INT I;

Cout << "Please enter the location where you want to delete the data item:> /";

CIN >> I;

While (i <1 || i> l.getlen ())

{

Cout << "Enter is incorrect, may be larger with the length of the list, please enter from the new input!" << Endl;

COUT << "> /";

CIN >> I;

}

L.Delnode (i);

}

Template

Void List_makeempty (list & l)

{

L.makeempty ();

}

Template

Void List_Print (List & l)

{

IF (! l.print ())

Cout << "The list is empty!" << Endl;

}

转载请注明原文地址:https://www.9cbs.com/read-102105.html

New Post(0)