반응형
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static String check(int[] numArr) {
String str = "mixed";
boolean asc = true;
boolean desc = true;
for(int i = 1; i <= numArr.length; i++) {
if(numArr[i - 1] != i) asc = false;
if(numArr[i - 1] != numArr.length - i + 1) desc = false;
}
if(asc) str = "ascending";
if(desc) str = "descending";
return str;
}
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String input = br.readLine();
StringTokenizer st = new StringTokenizer(input);
int size = st.countTokens();
int[] numArr = new int[size];
for(int i = 0; i < size; i++) {
numArr[i] = Integer.parseInt(st.nextToken());
}
}
public static String check2(int[] input) {
String result = "mixed";
int[] ascending = new int[input.length];
int[] descending = new int[input.length];
for(int i = 0; i < input.length; i++) {
ascending[i] = i + 1;
descending[i] = input.length - i;
}
boolean asc = true;
boolean desc = true;
for(int i = 0; i < input.length; i ++) {
if(ascending[i] != input[i]) asc = false;
if(descending[i] != input[i]) desc = false;
}
if(asc) result = "ascending";
else if(desc) result = "descending";
return result;
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
반응형
'IT > 알고리즘' 카테고리의 다른 글
백준 5단계(3052) (0) | 2019.11.28 |
---|---|
백준 5단계(2577) (0) | 2019.11.28 |
코테 11/25/19 (0) | 2019.11.25 |
기초 알고리즘(38번 치킨쿠폰 재귀) (0) | 2019.11.24 |
백준 5단계(2562) (0) | 2019.11.24 |