当前位置: 代码迷 >> 综合 >> HDOJ 1859 最小长方形
  详细解决方案

HDOJ 1859 最小长方形

热度:18   发布时间:2023-10-21 19:04:17.0

HDACM 1859

求最大值和最小值,水题

import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);while(sc.hasNext()){int x = sc.nextInt();int y = sc.nextInt();int min_x = x;int min_y = y;int max_x = x;int max_y = y;if (min_x == 0 && min_y == 0) {break;}while (true) {x = sc.nextInt();y = sc.nextInt();if (x==0 && y==0) {break;}if (x>max_x) {max_x = x;}if (y>max_y) {max_y = y;}if (x<min_x) {min_x = x;}if (y<min_y) {min_y = y;}}System.out.println(min_x+" "+min_y+" "+max_x+" "+max_y);}sc.close();}
}