package AlgorithmEasy;
import java.util.Arrays;
import java.util.Scanner;
public class Algorithm29 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] input = new int[8];
String result = "";
System.out.println("1부터 8까지의 수를 입력하세요 >> ");
for(int i = 0; i < input.length; i++) {
input[i] = sc.nextInt();
}
//System.out.print(Arrays.toString(input));
Lable:for(int i = 0; i < input.length-1; i++) { // 0 1 2 3 4 5 6
for(int j = i+1; j < input.length; j++) { //
if(input[i]+1 == input[j]) { //오름차순인 경우
result = "ascending";
break;
}else if(input[i]-1 == input[j]) { //내림차순인 경우
result = "descending";
break;
}else { //한번이라도 여기들어오면 끝
result = "mixed";
break Lable;
}
}
}
System.out.println(result);
}
}
'알고리즘 문제연습 > 기초 알고리즘' 카테고리의 다른 글
[프로그래머스] 실패율 (0) | 2023.02.13 |
---|---|
[030] 더하기 빼기 번갈아가면서 출력 (0) | 2021.06.17 |
[026] 상수 (백준 2908번) (0) | 2021.06.15 |
[025] 더하기 사이클 (백준 1110번) (0) | 2021.06.09 |
[023] 문자열 뒤집기 (0) | 2021.06.09 |
댓글