๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ˜์‘ํ˜•

์ „์ฒด ๊ธ€743

[๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜] 10951๋ฒˆ - A+B - 4 4. while๋ฌธ - A+B - 4 ๋ฌธ์ œ) ๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…๋ ฅ ์ถœ๋ ฅ 1 1 2 3 3 4 9 8 5 2 2 5 7 17 7 import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { // ์ž…๋ ฅ๊ฐ’์ด int๋ฉด true๋ฅผ ๋ฐ˜ํ™˜ํ•˜์—ฌ while๋ฌธ์„ ์‹คํ–‰/ int a = sc.nextInt(); // ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด false๋ฅผ ๋ฐ˜ํ™˜ํ•˜์—ฌ while๋ฌธ ์ข…๋ฃŒ. int b = sc.nextInt(); System.out.println(a + b); // .. 2021. 2. 1.
[๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜] 10952๋ฒˆ - A+B - 5 4. while๋ฌธ - A+B - 5 ๋ฌธ์ œ) ๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…๋ ฅ์˜ ๋งˆ์ง€๋ง‰์—๋Š” 0 ๋‘ ๊ฐœ๊ฐ€ ๋“ค์–ด์˜จ๋‹ค. ์ž…๋ ฅ ์ถœ๋ ฅ 1 1 2 3 3 4 9 8 5 2 0 0 2 5 7 17 7 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) { // a์™€ b๊ฐ€ 0์ด๋ฉด ๋ฉˆ์ถค break; // while๋ฌธ ๋น ์ ธ.. 2021. 2. 1.
[๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜] 10871๋ฒˆ - X๋ณด๋‹ค ์ž‘์€ ์ˆ˜ 3. for๋ฌธ - X๋ณด๋‹ค ์ž‘์€ ์ˆ˜ ๋ฌธ์ œ) ์ •์ˆ˜ N๊ฐœ๋กœ ์ด๋ฃจ์–ด์ง„ ์ˆ˜์—ด A์™€ ์ •์ˆ˜ X๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์ด๋•Œ, A์—์„œ X๋ณด๋‹ค ์ž‘์€ ์ˆ˜๋ฅผ ๋ชจ๋‘ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…๋ ฅ ์ถœ๋ ฅ 10 5 1 10 4 9 2 3 8 5 7 6 1 4 2 3 import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); // 10 int X = sc.nextInt(); // 5 int a[] = new int[N]; for (int i = 0; i < N; i++) { // ๋ฐฐ์—ด ์ˆ˜(N) ๋๊นŒ์ง€ ์ถœ๋ ฅ a[i] = sc.nextInt.. 2021. 2. 1.
[๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜] 2439๋ฒˆ - ๋ณ„ ์ฐ๊ธฐ - 2 3. for๋ฌธ - ๋ณ„ ์ฐ๊ธฐ 2 ๋ฌธ์ œ) ์ฒซ์งธ ์ค„์—๋Š” ๋ณ„ 1๊ฐœ, ๋‘˜์งธ ์ค„์—๋Š” ๋ณ„ 2๊ฐœ, N๋ฒˆ์งธ ์ค„์—๋Š” ๋ณ„ N๊ฐœ๋ฅผ ์ฐ๋Š” ๋ฌธ์ œ ํ•˜์ง€๋งŒ, ์˜ค๋ฅธ์ชฝ์„ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌํ•œ ๋ณ„(์˜ˆ์ œ ์ฐธ๊ณ )์„ ์ถœ๋ ฅํ•˜์‹œ์˜ค. ์ž…๋ ฅ ์ถœ๋ ฅ 5 * ** *** **** ***** import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 1; i i; j--) { // j๋Š” n์ด๊ณ  j๊ฐ€ i๋ณด๋‹ค ํด๋•Œ j๋ฅผ ๊ฐ์†Œ System.out.print(" "); // ๊ณต๋ฐฑ ์ถœ๋ ฅ. ๊ณต๋ฐฑ4์นธ-3์นธ-2์นธ-1์นธ ์ˆœ } for (int k = 0; .. 2021. 1. 31.
[๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜] 2438๋ฒˆ - ๋ณ„ ์ฐ๊ธฐ - 1 3. for๋ฌธ - ๋ณ„ ์ฐ๊ธฐ - 1 ๋ฌธ์ œ) ์ฒซ์งธ ์ค„์—๋Š” ๋ณ„ 1๊ฐœ, ๋‘˜์งธ ์ค„์—๋Š” ๋ณ„ 2๊ฐœ, N๋ฒˆ์งธ ์ค„์—๋Š” ๋ณ„ N๊ฐœ๋ฅผ ์ฐ๋Š” ๋ฌธ์ œ ์ž…๋ ฅ ์ถœ๋ ฅ 5 * ** *** **** ***** import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 0; i < n; i++) { // i๋Š” 0์ด๊ณ  i๊ฐ€ n๋ณด๋‹ค ์ž‘์„๋•Œ i๊ฐ’ ์ถœ๋ ฅ ํ›„ ์ฆ๊ฐ€ for (int j = 0; j 2021. 1. 31.
[๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜] 11022๋ฒˆ - A+B - 8 3. for๋ฌธ - A+B - 8 ๋ฌธ์ œ) ๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…๋ ฅ ์ถœ๋ ฅ 5 1 1 2 3 3 4 9 8 5 2 Case #1: 1 + 1 = 2 Case #2: 2 + 3 = 5 Case #3: 3 + 4 = 7 Case #4: 9 + 8 = 17 Case #5: 5 + 2 = 7 import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 1; i 2021. 1. 31.
๋ฐ˜์‘ํ˜•