YÊU CẦU:
Input: file DAYSO.INP gồm:
• Dòng 1 chứa số n không quá 100
• Dòng 2 ghi n số nguyên không quá 9 chữ số (có thể ngẫu nhiên).
Cài đặt thuật toán sắp xếp chọn. Ghi ra file SXCHON.OUT tất cả các bước thực hiện thuật toán
Đây là đoạn code của em. Lỗi vào ra cơ bản 
import java.util.*;
import java.io.*;
public class Bai01 {
public static void docFile(int a[], int n, Scanner in) {
for (int i = 0; i < n; i++) {
a[i] = in.nextInt();
}
}
public static void selection_sort(int a[], int n) {
for (int i = 0; i < n - 1; i++) {
int min = i;
for (int j = i + 1; j < n; j++) {
if (a[j] < a[min]) {
min = j;
}
}
if (min != i) {
int temp = a[min];
a[min] = a[i];
a[i] = temp;
}
ghiFile(a,out); // LỖI Ở CHỖ NÀY
}
}
public static void ghiFile(int a[], PrintWriter out) {
for (int i = 0; i < a.length; i++) {
out.print(a[i] + " ");
}
}
public static void main(String[] args) {
int n, a[] = new int[100];
try {
Scanner in = new Scanner(new File("DAYSO.INP"));
PrintWriter out = new PrintWriter(new File("SAPXEPCHON.OUT"));
n = in.nextInt();
docFile(a, n, in);
selection_sort(a, n);
ghiFile(a, out);
out.close();
} catch (Exception e) {
System.out.println("Co loi xay ra " + e.toString());
}
}
}
Em cảm ơn nhiều ạ ! Mong anh chị cùng giúp đỡ.


83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?