Linked List Starter


使用這段程式開始你的Linked List實作

#include<bits/stdc++.h>
using namespace std;

// TODO: 建立一個struct Node,裡面要有int data跟Node *next

int main()
{

    Node *head= NULL, *tail, *ptr, *temp, *prev, *next;
    int selection, value, key, found, index, i;

    while (1) //重複執行選單畫面
    {
        system("cls"); // 清空畫面
        cout << "==== Function List ====" << endl;
        cout << "[1] Create linked list"<<endl;
        cout << "[2] Push the Node after last Node"<<endl;
        cout << "[3] Delete the last Node"<<endl;
        cout << "[4] Display whole linked list" << endl;
        cout << "[5] Search Node"<<endl;
        cout << "[6] Insert a Node before given position"<<endl;
        cout << "[7] Delete a Node at a given position"<<endl;
        cout << "[8] Reverse linked list" << endl;
        cout << "==================" << endl << endl;
        cout << "Enter function number:";

        cin >> selection; //選擇要使用第幾個功能

        switch (selection)
        {

        case 1: // Create linked list

            //TODO: 建立第一個Node

            break;

        case 2: // Push the Node after last Node

            //TODO: 在尾端插入Node

            break;

        case 3: // Delete the last Node

            //TODO: 刪除最後一個Node

            break;

        case 4: // Display whole linked list

            //TODO: 顯示整個Linked list

            break;

        case 5: // Search Node

            //TODO: 搜尋

            break;

        case 6: // Insert a Node before given position

            //TODO: 插入Node至指定位置

            break;

        case 7: // Delete a Node at a given position

            //TODO: 刪除指定位置的Node

            break;

        case 8: // Reverse linked list

            //TODO: 顛倒(reverse)

            break;
        }
    }
}

results matching ""

    No results matching ""