main.cpp

来自「对链表进行排序 应用了多种排序方法 对其进行比较 有自己的详细的时间函数」· C++ 代码 · 共 68 行

CPP
68
字号
#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 + =
减小字号Ctrl + -
显示快捷键?