⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testproglinkedlist.cpp

📁 C++编成数据结构与程序设计方法 D.S.Malk编著
💻 CPP
字号:
//This program tests various operation of a linked list
//Hello There Show White Bear Brown Black Green Hat C++
 
#include <iostream>
#include <string>
#include "unorderedLinkedList.h"

using namespace std;

int main()
{
    unorderedLinkedList<string> list1, list2;       //Line 1
    string str;                                     //Line 2

    cout << "Line 3: Enter 10 strings." << endl;    //Line 3

    for (int i = 0; i < 10; i++)                    //Line 4
    {
        cin >> str;                                 //Line 5
        list1.insertLast(str);                      //Line 6
    }

    cout << endl;                                   //Line 7

    cout << "Line 9: list1: ";                      //Line 8
    list1.print();                                  //Line 9
    cout << endl;                                   //Line 10
    cout << "Line 12: Length of list1: " 
         << list1.length() << endl;                 //Line 11

    list2 = list1;	   //test the assignment operator Line 12

    cout << "Line 16: list2: ";                     //Line 13
    list2.print();                                  //Line 14
    cout << endl;                                   //Line 15
    cout << "Line 17: Length of list2: " 
         << list2.length() << endl;                 //Line 16

    cout << "Line 18: Enter the string to be "
         << "deleted: ";                            //Line 17
    cin >> str;                                     //Line 18
    cout << endl;                                   //Line 19

    list2.deleteNode(str);                          //Line 20
	
    cout << "Line 24: After deleting " << str 
         << " list2: " << endl;                     //Line 21
    list2.print();                                  //Line 22
    cout << endl;                                   //Line 23

    cout << "Line 24: Length of list2: " 
         << list2.length() << endl;                 //Line 24

    cout << endl << "Line 25: Output list1 " 
         << "using an iterator" << endl;            //LIne 25

    linkedListIterator<string> it;                  //Line 26

    for (it = list1.begin(); it != list1.end(); 
                             ++it)                  //Line 27
        cout << *it << " ";                         //Line 28
    cout << endl;                                   //Line 29

    return 0;					
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -