← 목록

정보처리기사 실기 2023년 1회

이전
Q.202023년1회10과목 · Java배점 5점
다음 Java 프로그램에서 빈칸 (1)과 (2)에 들어갈 코드를 쓰시오.
public class Sort {
  public static void swap(int[] arr, int idx1, int idx2) {
    int temp = arr[idx1];
    arr[idx1] = arr[idx2];
    arr[(  ①  )] = temp;
  }

  public static void Usort(int[] array, int length) {
    for (int i = 0; i < length; i++) {
      for (int j = 0; j < length - i - 1; j++) {
        if (array[j] > array[j + 1]) {
          swap(array, j, j + 1);
        }
      }
    }
  }

  public static void main(String[] args) {
    int[] item = new int[] { 5, 3, 8, 1, 2, 7 };
    int nx = 6;
    Usort(item, (  ②  ));
    for (int data : item) {
      System.out.print(data + " ");
    }
  }
}
댓글…

나만의 풀이, 암기법을 나눠 보세요. 정답이 포함될 수 있어요.

해설
왼쪽에서 보기를 고르고 정답 확인을 누르면
여기에 정답과 해설이 표시됩니다.