문제 : http://59.23.113.171/pool/koi_reversal/koi_reversal.php?pname=koi_reversa
import java.util.Scanner;
public class Main {
public Main() {
// TODO Auto-generated constructor stub
int number[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
int input[] = new int[2];
Scanner scan = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 2; j++) {
input[j] = scan.nextInt();
}
sort(number,input);
}
print(number);
}
public void sort(int[] number, int[] input){
int count = 0;
if ((input[1]-input[0])%2 == 0) {
count = (input[1]-input[0])/2;
}else{
count = ((input[1]-input[0])/2)+1;
}
int a=0;
for (int i = 0; i < count; i++) {
int temp = number[input[0]-1+a];
number[input[0]-1+a] = number[input[1]-1-a];
number[input[1]-1-a] = temp;
a++;
}
}
public void print(int[] number){
for (int i = 0; i < number.length; i++) {
System.out.print(number[i] + " ");
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new Main();
}
}