내림차순 정렬
public class SortTest {
public static void main(String[] args) {
int score[] = new int[10];
int i, j;
System.out.println("i 값 : ");
// i, j값 랜덤 값 생성
for(i=0;i<score.length;i++){
score[i] = (int) (Math.random() * 10);
System.out.print(score[i]);
}
System.out.println("");
System.out.println("j 값 : ");
for(j=0;j<score.length;j++){
score[j] = (int) (Math.random() * 10);
System.out.print(score[j]);
}
System.out.println();
for (i = 0; i < score.length; i++) {
for (j = i+1; j < score.length; j++) {
if (score[i] <= score[j]) {
int temp = score[i];
score[i] = score[j];
score[j] = temp;
}
}
}
// 내림 차순 정렬
for (i = 1; i < score.length; i++) {
System.out.print(score[i]+"\t");
}
}
}