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

📄 main.cpp

📁 对链表进行排序 应用了多种排序方法 对其进行比较 有自己的详细的时间函数
💻 CPP
字号:
#include <iostream>
#include"InsertSort.h"
#include"MergeSort.h"
#include"Timer.h"
#include"fill.h"
#include "bubble.h"
#include "Select.h"
int const LENGTH=20;
using namespace std;



int main() 
{ 
    int data[LENGTH];
    fill(data,LENGTH);
    pNode pdf;
    pNode temp;
    pNode temp1;
    pNode temp2;
    pNode pNew;
    pNode pLast,pLast2,pLast3,pLast4;
    Timer time;
    
    pdf=sCreate(data,LENGTH); 
    temp=pdf;
    temp1=pdf;
    temp2=pdf;
    cout<<"----------the orginal datas ------"<<endl;
    sPrint(pdf);
    
    pLast=insertsort (pdf);
    time.start();
    cout<<"---------use insert sort---------"<<endl;
    sPrint(pLast);
    cout<<"---------------------------------"<<endl;
    time.stop();
    cout<<"use"<<time.seconds()<<"s"<<endl;
    
    pLast3=BubbleLinkListSort (temp1);
    time.start();
    cout<<"---------use bubble sort---------"<<endl;
    sPrint(pLast3);
    cout<<"---------------------------------"<<endl;
    time.stop();
    cout<<"use"<<time.seconds()<<"s"<<endl;
    
    pLast4=SelectLinkListSort (temp2);
    time.start();
    cout<<"---------use select sort---------"<<endl;
    sPrint(pLast4);
    cout<<"---------------------------------"<<endl;
    time.stop();
    cout<<"use"<<time.seconds()<<"s"<<endl;
    
    cout<<"---------use merge sort ---------"<<endl;
    time.reset();
    time.start();
    pLast2=MergeSort(temp);
    sPrint(pLast);
    time.stop();
    cout<<"use"<<time.seconds()<<"s"<<endl;
    cout<<"---------------------------------"<<endl;
    
    system("pause"); 
    return 0; 
} 

⌨️ 快捷键说明

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