Article
测试排序算法样板方法
2011/8/8 13:16:46
#include "stdafx.h"     | 
#include <iostream>     | 
using namespace std;    | 
   | 
const int N = 10;  | 
   | 
void InsertSort(int *a, int len);  | 
void ShellSort(int *a, int len);  | 
   | 
int main()     | 
{    | 
    int a[N] = {49,38,65,97,76,13,27,10,22,55};  | 
    cout << "Before sort: "<<endl;  | 
    for (int i = 0;i < N; ++i)  | 
    {  | 
        cout << a[i] << " ";  | 
    }  | 
   | 
    //InsertSort(a, N);  | 
    ShellSort(a, N);  | 
   | 
    cout << "\nAfter sort: "<<endl;  | 
    for (int i = 0;i < N; ++i)  | 
    {  | 
        cout << a[i] << " ";  | 
    }  | 
    return 0;    | 
} |