andy6804tw
7/16/2016 - 10:15 AM

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=25165 這題就是很簡單的距離d的排序然後相對印出x,y

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=25165 這題就是很簡單的距離d的排序然後相對印出x,y

import java.util.*;
 
public class Main {
 
 public static void main(String[] args) {
  Scanner scn = new Scanner(System.in);
  int n = scn.nextInt(), arr[][] = new int[n][3], ary[] = new int[n];
  for (int i = 0; i < n; i++) {
   arr[i][0] = scn.nextInt();
   arr[i][1] = scn.nextInt();
   arr[i][2] = scn.nextInt();
   ary[i] = arr[i][2];
  }
  Arrays.sort(ary);
  for (int i = 0; i < n; i++) {
   for (int j = 0; j < n; j++) {
    if (arr[j][2] == ary[i]) {
     System.out.println(arr[j][0] + " " + arr[j][1] + " " + arr[j][2]);
     break;
    }
   }
  }
 
 }
 /* 
    題目:[Problem 3] Distance Sorting
    作者:1010
    時間:西元 2016 年 7 月 */
}