JAVA-BAEKJOON (38) 썸네일형 리스트형 [백준/04-06] 10813 공 바꾸기 NO.10813 풀이코드 import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int arr[] = new int[N]; int M = sc.nextInt(); int temp; for(int i = 0; i < arr.length; i++) { arr[i] = i + 1; } for(int j = 0; j < M; j++) { int I = sc.nextInt(); int J = sc.nextInt(); temp = arr[I-1]; arr[I-1] = arr[J-1]; arr[J-1] = temp;.. [백준/04-05] 10810 공 넣기 NO.10810 풀이코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int arr[] = new int[N]; int M = sc.nextInt(); for(int i=0; i [백준/04-04] 2562 최댓값 NO.2562 풀이코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int arr[] = new int[9];// 숫자 9개를 담을 배열 생성 for(int i=0; i max) {// 인덱스로 선택된 배열 내 값과 max 값을 비교해 max = value;// max 가 더 크면 max 에 값을 변경하여 저장 i.. [백준/04-03] 10818 최소, 최대 NO.10818 풀이코드 import java.util.Scanner; public class _10818 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int arr[] = new int[N]; for(int i=0;i [백준/04-02] 10871 X보다 작은 수 NO.10871 풀이코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int arr[] = new int[N]; int X = sc.nextInt(); for(int i=0; i [백준/04-01] 10807 개수 세기 NO.10807 풀이코드 import java.util.Scanner; public class Main { public static void main(String[] arge) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int arr[] = new int[N]; for(int i=0;i [백준/03-12] 10951 A+B - 4 NO.10951 풀이코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 입력데이터를 숫자로 받으며 EOF를 체크 while(sc.hasNextInt()) {// EOF인 경우 false -> 반복문 빠져나옴 int A = sc.nextInt(); int B = sc.nextInt(); System.out.println(A+B); } sc.close(); } } 📌 종료되는 조건이 없다는 것만 빼면 직전 문제랑 똑같다. 문제는 그것때문에 막혔다는거... "조건없는 input 종료"로 검색했는데 원하는 자료가 안나오다가 끝자락에 .. [백준/03-11] 10952 A+B - 5 NO.10952 풀이코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true) { int A = sc.nextInt(); int B = sc.nextInt(); if(A==0 && B==0) { break; } else { System.out.println(A+B); } } sc.close(); } } 📌 지금까지와는 다르게 몇 개의 연산을 진행할지 먼저 지정하지 않는다. 몇 개의 연산이 들어올지 모르는 상황. 그럼 무한루프를 만들어 조건을 만족할때(A==0,B==0)일때 멈추는 걸로 만들면 된다. While 에 tr.. 이전 1 2 3 4 5 다음 목록 더보기