Score 배열을 오름차순 정렬할려고 제가 코드를 짜봤는데 왜 안될까요..
아래는 함수 코드입니다.
private static void ExchangeValue(int[] Score, int location1, int location2)
{
int temp;
temp = Score[location1];
Score[location1] = Score[location2];
Score[location2] = temp;
}
private static void SelectionSort(int[] Score, int aSize)
{
int count1 = 0;
int count2 = 0;
int minLocation = 0;
while(count1
{
while(count2
{
if(Score[count2] <= Score[count1])
{
minLocation = count2;
}
count2++;
}
ExchangeValue(Score, count1, minLocation);
count1++;
count2 = count1;
}
}
입력 82, 45, 93, 66, 87
결과 66 45 87 82 93
도저히 모르겠습니다..
제가 배운게 if while 밖에 없어서 제가 쓴 범위 안에서 설명 부탁드립니다.
댓글 0