Algorithm Intro - Bubble Sort




void bubble_sort(vector<int> &v)
{
    for(int i = 0; i < v.size(); i++) {
        for(int j = 1; j < v.size() - i; j++) {
            if(v[j - 1] <= v[j]) continue;
            int t = v[j -1];
            v[j - 1] = v[j];
            v[j] = t;
        }
    }

    return;
}



你可能感兴趣的:(Algorithm Intro - Bubble Sort)