Selection Sort

void SelectionSort( vector<int> &v) {
    for ( int i = 0, m = 0; i < v.size(); i++, m = i ) {
        for ( int j = i; j <v.size(); j++ ) {
            if ( v[j] < v[i] ) {
                m = j;
                int t = v[m];
                v[m] = v[i];
                v[i] = t;
            }
        }
    } 
}
posted @ 2012-12-01 17:42  tsubasa_wp  阅读(161)  评论(0编辑  收藏  举报