?? bublesort.cpp
字號:
////////////////
// 起泡排序 //
////////////////
#include "iostream.h"
#include "stdlib.h"
#include "string.h"
#include "Compare.h"
#include "BubleSorter.h"
// 設定隨即函數的種子
inline void Randomize()
{ srand(1); }
//返回一個0到n-1之間的隨機數
inline int Random(int n)
{ return rand() % (n); }
void main()
{
//產生隨機數組,長度為100
Randomize();
int * sortarray =new int[100];
for(int i=0;i<100;i++)
sortarray[i]=Random(100);
//實例化起泡排序類
BubleSorter<int,Compare> sorter;
//輸出排序前數組內容
cout<<"排序前:";cout<<endl;
sorter.PrintArray(sortarray,100);
//排序
sorter.Sort(sortarray,100);
//輸出排序后數組內容
cout<<"排序后:";cout<<endl;
sorter.PrintArray(sortarray,100);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -