반응형
public class Q_2750 {

	public void mySol() {
		int[] array = new int[1000];
		int min, j, k, temp;
		
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int count = Integer.parseInt(br.readLine());
			for (int i = 0; i < count; i++) {
				array[i] = Integer.parseInt(br.readLine());
			}
			
			for (j=0; j <count; j++) {
				min = j;
				for (k=j; k<count; k++) {
					if(array[k] < array[min]) {
						min = k;
					}
				}
				temp = array[j];
				array[j] = array[min];
				array[min] = temp;
			}
			
			for (int l=0; l<count; l++) {
				System.out.println(array[l]);
			}
			
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) throws IOException {
		Q_2750 q = new Q_2750();
		q.mySol();
	}
}

 

URL :  www.acmicpc.net/problem/2750

 

반응형

+ Recent posts