메뉴 건너뛰기

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);

}
박영식 (비회원)
    • 글자 크기

댓글 달기

suritam9
2013.12.02 조회 3162
lispro06
2017.06.22 조회 1617
suritam9
2019.04.05 조회 1851
lispro06
2013.12.10 조회 2739
lispro06
2014.02.08 조회 3806
이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (0)
위로