새소식

인기 검색어

비트교육_단기과정

알고리즘 2번 문제

  • -
package week_4;
 
import java.util.*;
 
public class SecondExam {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        SecondExam.result(sc.nextInt(), sc.nextInt());
    }
 
    public static void result(int x, int y) {// x = 100, y = 600
        ArrayList<Integer> al = new ArrayList<Integer>();
        for (int i = x + 1; i < y; i++) {// 101~ 599
            String ti = String.valueOf(i);// ti = 101
            for (int j = 0; j < ti.length(); j++) {// 3
                if (j == ti.length() - 1) {
                    al.add(i);
                    break;
                } else if (Character.compare(ti.charAt(j), ti.charAt(j + 1)) >= 0) {
                    break;
                }
            }
        }
        for (int i = 0; i < al.size(); i++) {
            System.out.print(al.get(i) + " ");
        }
        System.out.println();
        System.out.println("갯수:" + al.size());
    }
}
 
cs

'비트교육_단기과정' 카테고리의 다른 글

야구게임 1000번 평균횟수 5회  (0) 2022.07.13
알고리즘 3번 : 마기창  (0) 2022.07.12
알고리즘 1번 문제  (0) 2022.07.11
로또 : 마기창  (0) 2022.07.11
Map<E> 성적관리  (0) 2022.07.08
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.