[알고리즘/백준] 2920 음계(자바)

[알고리즘/백준] 2920 음계(자바)

문제

https://www.acmicpc.net/problem/2920

풀이 코드

public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[] ascending = {1, 2, 3, 4, 5, 6, 7, 8}; int[] descending = {8, 7, 6, 5, 4, 3, 2, 1}; int[] arr = new int[8]; StringTokenizer st = new StringTokenizer(br.readLine()); for (int i = 0; i < 8; i++) { arr[i] = Integer.parseInt(st.nextToken()); } if (Arrays.equals(arr, ascending)) { System.out.println("ascending"); } else if (Arrays.equals(arr, descending)) { System.out.println("descending"); } else { System.out.println("mixed"); } } }

728x90

from http://developer-hm.tistory.com/153 by ccl(A) rewrite - 2021-09-19 16:01:27