Banner

My Tech Blog (์ฝ”๋“œ)

โœ… ๋ฌธ์ œ10์ง„์ˆ˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„ 2์ง„์ˆ˜๋กœ ๋ณ€ํ™˜ํ•ด์„œ ์ถœ๋ ฅํ•˜์‹œ์˜ค. โœ… ์ฝ”๋“œimport java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); int[] leejin = new int[20]; for (int i = 0; i = 0; i--){ System.out.print(leejin[i]); } }}โœ… ์ถ”๋ก  ๊ณผ์ •์‹ญ์ง„์ˆ˜๋ฅผ ์ด์ง„์ˆ˜๋กœ ๋งŒ๋“ค์–ด์ฃผ๋ ค๋ฉด 2๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ ํ™œ์šฉํ•ด์ฃผ๋ฉด ๋œ๋‹ค.์‹ญ์ง„์ˆ˜๋ฅผ 2๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ ๊ณ„์†ํ•ด์„œ ๊ตฌํ•ด์„œ,..
โœ… ๋ฌธ์ œ๋‹จ ์ˆ˜์™€ ๊ณฑํ•ด์ง€๊ธธ ์›ํ•˜๋Š” ์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ์ด์™€ ๊ฐ™์ด ์ถœ๋ ฅ๋˜๊ฒŒ ํ•˜์‹œ์˜ค โœ… ์ฝ”๋“œimport java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a; int b; System.out.print("๋‹จ์ˆ˜์ž…๋ ฅ: "); a = sc.nextInt(); System.out.print("์–ด๋Š ์ˆ˜๊นŒ์ง€ ์ถœ๋ ฅ: "); b = sc.nextInt(); for (int i = 1; i โœ… ์ถ”๋ก  ๊ณผ์ •์–ด๋Š ๊ตฌ๊ฐ„์ด ๋ฐ˜๋ณต๋˜๋Š”์ง€ ๋ฌถ์–ด ๋ณด๋ฉด์„œ ๋ฐ˜๋ณต๋ฌธ์„ ์—ด์–ด ์ฃผ๋ฉด ๋œ๋‹ค.์ž…..
โœ… ๋ฌธ์ œ์ค‘๋ณต์ด ์—†์ด ์ˆซ์ž๋ฅผ ๋ฝ‘๋Š” ๋กœ๋˜ ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“œ์‹œ์˜ค โœ… ์ฝ”๋“œimport java.util.Random;public class Main { public static void main(String[] args) { Random r = new Random(); int a = 0; int[] lotto = new int[6]; for (int i = 0; i  โœ… ์ถ”๋ก  ๊ณผ์ •์ž๋ฐ”์—์„œ ๋‚œ์ˆ˜(๋žœ๋ค์ˆ˜) ๋งŒ๋“œ๋Š” ๊ฐ์ฒด Randomrandom ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ๋Š” ๋ฐ˜๋“œ์‹œ import ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค.Random ๋žœ๋ค๋ณ€์ˆ˜๋ช… = new Random(); ๋ณ€์ˆ˜๋ช… = ๋žœ๋ค๋ณ€์ˆ˜๋ช….nextInt(๋ฒ”์œ„์ˆ˜)+์‹œ์ž‘์ˆซ์ž;์—ฌ๊ธฐ์„œ ์ค‘์š”ํ•œ ๋ถ€๋ถ„์€ ์ค‘๋ณต์ด ์—†์ด ์ˆซ์ž๋ฅผ ๋ฝ‘์•„์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฒˆํ˜ธ๋ฅผ ๋ฝ‘๊ณ  ๋‚˜์„œ ์ˆซ์ž๋ฅผ ๋ฐฐ์—ด์— ๋„ฃ์–ด์ฃผ๊ณ , for๋ฌธ..
โœ… ๋ฌธ์ œ์ˆซ์ž๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„ 3์˜ ๋ฐฐ์ˆ˜์ธ ์ˆซ์ž๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์„ธ์š”. โœ… ์ฝ”๋“œimport java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] nums = new int[10]; for (int i = 0; i โœ… ์ถ”๋ก  ๊ณผ์ • ๋˜๊ฒŒ ์‰ฌ์šด ๋ฌธ์ œ์˜€๋‹ค. ์ผ๋‹จ ์ˆซ์ž๋ฅผ 10๋ฒˆ ์ž…๋ ฅ๋ฐ›์œผ๋‹ˆ๊นŒ 10์นธ์งœ๋ฆฌ ๋ฐฐ์—ด์„ ์„ ์–ธํ•ด์ค€๋‹ค.๋ฐ˜๋ณต๋ฌธ์„ ๋Œ๋ ค์„œ ์ž…๋ ฅ๋ฐ›์€ ์ˆซ์ž๋ฅผ ๋ฐฐ์—ด์— ์ง‘์–ด ๋„ฃ์–ด ์ค€๋‹ค. ๋ฐฐ์—ด์˜ ๊ธธ์ด๋งŒํผ ๋ฐ˜๋ณต๋ฌธ์„ ๋Œ๋ ค์ฃผ๋ฉฐ ๋‹ด๊ธด ๊ฐ๊ฐ์˜ ์ˆซ์ž๋“ค์„ 3์œผ๋กœ ๋‚˜๋ˆ ์ฃผ๊ณ ,๋‚˜๋จธ์ง€๊ฐ€ 0์ด๋ฉด ํ•ด๋‹น ์ˆซ์ž๋ฅผ ์ถœ๋ ฅํ•ด ์ค€๋‹ค.
โœ… ๋ฌธ์ œ8์ž๋ฆฌ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ๋ฐ˜๋ณต๋ฌธ์„ ํ™œ์šฉํ•˜์—ฌ ์ž…๋ ฅ๋ฐ›์€ ์ •์ˆ˜์˜ ํ•ฉ์„ ๊ตฌํ•˜์—ฌ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. โœ… ์ฝ”๋“œimport java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("์ •์ˆ˜ ์ž…๋ ฅ : "); int num = sc.nextInt(); int result = 0; for (int i = 0; i  โœ… ์ถ”๋ก  ๊ณผ์ •๋‚ด๊ฐ€ ์ฒ˜์Œ์— ์ƒ๊ฐํ•ด๋‚ธ ๋ฐฉ๋ฒ•์€ 8์นธ์งœ๋ฆฌ ๋ฐฐ์—ด์„ ํ•˜๋‚˜ ์„ ์–ธํ•˜๋Š” ๊ฒƒ์ด์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ž…๋ ฅ๋ฐ›์€ ์ˆซ์ž๋ฅผ ํ•˜๋‚˜์”ฉ ์ชผ๊ฐœ์„œ ์นธ์— ์ง‘์–ด ๋„ฃ๊ณ  for๋ฌธ์„ ๋Œ๋ ค ๋ฐฐ์—ด ์š”์†Œ๋ฅผ ๊บผ๋‚ด ์˜ค๋ฉด์„œ ๋ˆ„์ ํ•ฉ์„ ์‹œ์ผœ์ฃผ๋ฉฐ ๋ณ€์ˆ˜์— ์ €์žฅํ•˜..
โœ… ๋ฌธ์ œ์ •์ˆ˜ n์„ ์ž…๋ ฅ๋ฐ›์•„ 1, 2, 4, 7, 11๊ณผ ๊ฐ™์€ ์ˆ˜์—ด์˜ n๋ฒˆ์งธ ํ•ญ๊นŒ์ง€ ์ถœ๋ ฅํ•˜์‹œ์˜ค. โœ… ์ฝ”๋“œimport java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("n ์ž…๋ ฅ : "); int n = sc.nextInt(); int result = 1; for (int i = 0; i โœ… ์ถ”๋ก  ๊ณผ์ • 1๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ด์„œ 1,2,3,4,5....์”ฉ ๋”ํ•ด๊ฐ€๋ฉฐ ์ˆซ์ž๋ฅผ ๋‚˜์—ดํ•˜๋Š” ๊ทœ์น™์ด ์žˆ๋‹ค. ์ฒ˜์Œ์— ์ •์ˆ˜ํ˜• ํƒ€์ž…์˜ result ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•ด์ฃผ๊ณ  1๋กœ ์ดˆ๊ธฐํ™” ํ•ด์คฌ๋‹ค.0๋ถ€ํ„ฐ n๊นŒ์ง€ for๋ฌธ์„ ๋Œ๋ ค๊ฐ€๋ฉฐ i๋ฅผ 1์”ฉ ์ฆ๊ฐ€์‹œ์ผœ์ค€๋‹ค.์ด๊ฑธ..
โœ… ๋ฌธ์ œ์ •์ˆ˜ N์„ ์ž…๋ ฅ ๋ฐ›์•„ N * N ๋ฐฐ์—ด์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆซ์ž๋ฅผ ์ €์žฅํ•˜๊ณ  ์ถœ๋ ฅํ•˜์‹œ์˜ค.โœ… ์ฝ”๋“œimport java.util.Scanner;public class SnakePatternArray { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the value of N: "); int N = scanner.nextInt(); int[][] array = new int[N][N]; int num = 1; for (int i = 0; i = 0; j--) {..
โœ… ๋ฌธ์ œํ•™์ƒ๋“ค์˜ ์„ฑ์  ์ •๋ณด๊ฐ€ ๋ฌธ์ž์—ด๋กœ ์„ ์–ธ๋˜์–ด ์žˆ์„ ๋•Œ, ๊ฐ ์„ฑ์  ๋ณ„ ํ•™์ƒ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜์‹œ์˜ค.  โœ… ์ฝ”๋“œimport java.util.Arrays;public class Main { public static void main(String[] args) { String score = "A,A,B,C,D,A,C,D,D,D,F"; String[] s = score.split(","); int[] result = { 0, 0, 0, 0, 0 }; for (int i = 0; i  โœ… ์ถ”๋ก  ๊ณผ์ •๋จผ์ € ์ŠคํŠธ๋ง ๋ฐฐ์—ด์„ ์„ ์–ธํ•ด์„œ ํ•™์ƒ๋“ค์˜ ์„ฑ์ ์„ ๋‹ด์•„์ค€๋‹ค. ๋ฌธ์ž์—ด์ด ํ•œ ์ค„๋กœ ๋˜์–ด ์žˆ์œผ๋ฏ€๋กœ .split() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ชผ๊ฐœ์ค˜์•ผ ํ•˜๋Š”๋ฐ ์ปด๋งˆ(,)๊ฐ€ ๊ตฌ๋ถ„์ž๊ฐ€ ๋œ๋‹ค.๊ทธ๋ฆฌ๊ณ  5๊ฐ€์ง€ ์•ŒํŒŒ๋ฒณ์˜ ๊ฐœ์ˆ˜๋ฅผ ์นด์šดํŒ…ํ•ด์ค„ 5์นธ์งœ๋ฆฌ ์ •..
์ธ์ ˆ๋ฏธ์˜€๋˜๊ฒƒ
'์ฝ”๋“œ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก (15 Page)
์ƒ๋‹จ์œผ๋กœ