새소식

인기 검색어

비트교육_단기과정

알고리즘 1번 문제

  • -
package week_4;
 
import java.util.*;
 
public class firstExam {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("4자리 정수를 입력하시오 : ");
        String num = sc.next();
        int[] arr = new int[4];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = Character.getNumericValue(num.charAt(i));
        }
        Arrays.sort(arr);//0235
        for (int i = 0; i < arr.length; i++) {
                for (int j = 1; j < arr.length; j++) {
                    if (arr[0== 0) {
                    int a = arr[0];
                    arr[0=arr[j];
                    arr[j]= a;
                }
            }//2035
        }
        for(int x : arr) {
            System.out.print(x);
        }
    }
}
 
cs

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

알고리즘 3번 : 마기창  (0) 2022.07.12
알고리즘 2번 문제  (0) 2022.07.11
로또 : 마기창  (0) 2022.07.11
Map<E> 성적관리  (0) 2022.07.08
Set<E> 성적관리  (0) 2022.07.08
Contents

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

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