메뉴 건너뛰기

app

bubble과 selection sort

박영식2003.11.05 19:57조회 수 2464댓글 0

    • 글자 크기
void Csorts::selectionSort(int a[], int n)
{
                int last(n-1);
                int maxPos;

                while (last>0)
                {
                        view_course(a);
                        maxPos=maxSelect(a, last+1);
                        swapElements(a, maxPos, last);
                        last--;
                }
        
}
void Csorts::bubbleSort(int a[], int n)
{
        int i;
        for (i = n - 1; i > 0; i--)
                bubbleSortPhase(a, i);
}

void Csorts::bubbleSortPhase(int a[], int last)
{
   int pos;
//중간 과정 보기 함수
        view_course(a);
   for (pos = 0; pos < last - 1; pos++)
      if (a[pos] > a[pos+1])
         swapElements(a, pos, pos+1);

}
박영식 (비회원)
    • 글자 크기
[RSA] FLASH ZEROBOARD OUTLOGIN (by 박영식) [android] 갤럭시 S6 안드로이드 7.0 루팅 (by lispro06)

댓글 달기

이전 1 ... 3 4 5 6 7 8 9 10 11 12... 14다음
첨부 (0)
위로