void selsctionsort(int list[], int last) {

for (int current = 0; current < last; current++)

exchange(list, current, last);

return;


}



void exchange(int list[], int current, int last) {

int smallest = current;

for (int walker = current + 1; walker < last; walker++) {

if (list[walker] < list[smallest]) {

smallest = walker;

}

}

int temp = list[current];

list[current] = list[smallest];

list[smallest] = temp;

return;

}



이렇겐데 exchange 함수에서 smallest를 walker로저장하는거 까진알겟는데


그밑에서 갑자기 값을 왜 current와 smallest 값을 바꿔요??


if문으로 walker랑 smallest를 비교했으면

walker 변수랑 smallest를 바꿔야되는거아니에요??

current는 walker-1값이라 바꾸면안될거같은데.. 내가 잘못생각하는건가??


설명좀해줄 멋쟁이 고추큰프갤형님구합니다 ㅠㅠ