-
백준 10818번 최소, 최대Programming/BaekJoon 2021. 7. 16. 12:57
public class 최소최대 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine(); StringTokenizer st = new StringTokenizer(br.readLine()); //최소값, 최대값 int max = -1000001; int min = 1000001; while(st.hasMoreTokens()) { int x = Integer.parseInt(st.nextToken()); if(x > max) { max = x; } if(x < min) { min = x; } } System.out.printf("%d %d", min, max); } }
'Programming > BaekJoon' 카테고리의 다른 글
백준 2577번 숫자의 개수 (0) 2021.07.16 백준 2562번 최대값 (0) 2021.07.16 백준 1110번 더하기 사이클 v (0) 2021.07.15 백준 10951번 A+B - 4 (0) 2021.07.15 백준 10952번 A + B - 5 (0) 2021.07.15