문제 출처: https://www.acmicpc.net/problem/2920




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    // https://www.acmicpc.net/source/7557796 코드 참고
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String input = reader.readLine();
        
        if(input.equals("1 2 3 4 5 6 7 8"))
            System.out.println("ascending");
        else if(input.equals("8 7 6 5 4 3 2 1"))
            System.out.println("descending");
        else
            System.out.println("mixed");
    }
    // 다른 방법
    public static void sound(String input){
        String[] arr = input.split(" ");
        
        if(arr[0].equals("1")){
            for(int i=; i<=; i++){
                if(!arr[i-1].equals(String.valueOf(i))){
                    System.out.println("mixed");
                    return;
                }
            }
            System.out.println("ascending");
        }
        else if(arr[0].equals("8")) {
            for(int i=2, j=; i<=; i++, j--){
                if(!arr[i-1].equals(String.valueOf(j))){
                    System.out.println("mixed");
                    return;
                }
            }
            System.out.println("descending");
        }
        else {
            System.out.println("mixed");
        }
    }
}
cs



'Algorithm' 카테고리의 다른 글

백준 11654번: 아스키 코드  (0) 2018.10.20
백준 10039번: 평균 점수  (0) 2018.10.15
백준 8958번: OX퀴즈  (0) 2018.10.15
백준 2577번: 숫자의 개수  (0) 2018.10.15
백준 1152번: 단어의 개수  (0) 2018.10.15

+ Recent posts