Banner

My Tech Blog (์ „์ฒด ๊ธ€)

๐ŸŒˆ ๐ต๐‘’ ๐‘”๐‘Ÿ๐‘Ž๐‘ก๐‘’๐‘“๐‘ข๐‘™, ๐‘Ž ๐‘™๐‘–๐‘ก๐‘ก๐‘™๐‘’ ๐‘Ž๐‘๐‘๐‘Ÿ๐‘’๐‘๐‘–๐‘Ž๐‘ก๐‘–๐‘œ๐‘› ๐‘”๐‘œ๐‘’๐‘  ๐‘Ž ๐‘™๐‘œ๐‘›๐‘” ๐‘ค๐‘Ž๐‘ฆ โœจ๐ฟ๐‘–๐‘“๐‘’ ๐‘–๐‘  ๐‘Ž ๐‘š๐‘Ž๐‘”๐‘–๐‘. ๐ธ๐‘›๐‘—๐‘œ๐‘ฆ ๐‘Ž๐‘›๐‘‘ ๐ต๐‘Ÿ๐‘–๐‘›๐‘” ๐‘—๐‘œ๐‘ฆ.
โœ… ๋ฌธ์ œ์ •์ˆ˜ 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์นธ์งœ๋ฆฌ ์ •..
๐Ÿ“ JavaScript ๐Ÿ–ฅ๏ธ ๋ฐฐ์—ด(Array)๊ฐ์ฒด์˜ ๋ฉ”์„œ๋“œ ํ•˜๋‚˜์˜ ์ €์žฅ์†Œ์— ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•  ๋•Œ ๋ฐฐ์—ด์„ ์„ ์–ธํ•ด ์ฃผ๋Š”๋ฐ์š”์•„๋ž˜๋Š” ๋ฐฐ์—ด๊ณผ ๊ด€๋ จ๋œ ๋ฉ”์„œ๋“œ์™€ ์†์„ฑ์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ๋ฉ”์„œ๋“œ๋ฅผ ์ž˜ ์‚ฌ์šฉํ•˜๋ฉด ๋ฐฐ์—ด ์ˆœ์„œ๋ฅผ ๋ณ€๊ฒฝ ํ•  ์ˆ˜๋„ ์žˆ๊ณ , ๋ฐฐ์—ด ๊ฐ์ฒด์— ์ƒˆ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฝ์ž…ํ•˜๊ฑฐ๋‚˜ ์‚ญ์ œํ•˜๋Š” ๊ฒƒ๋„ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. โœ… Array ๊ฐ์ฒด์˜ ๋ฉ”์„œ๋“œ์™€ ์†์„ฑ ํ•œ ๋ˆˆ์— ๋ณด๊ธฐโ€‹์ข…๋ฅ˜๊ธฐ๋Šฅjoin(์—ฐ๊ฒฐ ๋ฌธ์ž)๋ฐฐ์—ด์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์—ฐ๊ฒฐ ๋ฌธ์ž ๊ธฐ์ค€์œผ๋กœ 1๊ฐœ์˜ ๋ฌธ์žํ˜• ๋ฐ์ดํ„ฐ๋กœ ๋ฐ˜ํ™˜reverse()๋ฐฐ์—ด์˜ ๋ฐ์ดํ„ฐ ์ˆœ์„œ๋ฅผ ๊ฑฐ๊พธ๋กœ ๋ฐ”๊พผ ํ›„ ๋ฐ˜ํ™˜sort()๋ฐฐ์—ด์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌslice(index1, index2)๋ฐฐ์—ด์˜ ๋ฐ์ดํ„ฐ ์ค‘ ์›ํ•˜๋Š” ์ธ๋ฑ์Šค ๊ตฌ๊ฐ„๋งŒํผ ์ž˜๋ผ์„œ ๋ฐฐ์—ด ๊ฐ์ฒด๋กœ ๊ฐ€์ ธ์˜ค๊ธฐsplice()๋ฐฐ์—ด์˜ ์ง€์ • ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜๊ณ  ๊ทธ ๊ตฌ๊ฐ„์— ์ƒˆ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฝ์ž…..
ยท Diary
I'm in my early 30. I've only lived 30 years but why do I feel like I've lived forever and I've already felt all the emotion that human could ever feel? And one of the biggest mysteries of my life is why I stopped being happy when I was 20, lol Is it just me or anyone else who kinda feel like this? to be honest people told me that I'm still young and there's so many things I can do. but from tim..
๐Ÿ“ JavaScript ๐Ÿ–ฅ๏ธ ๋ฐฐ์—ด ๊ฐ์ฒด(Array Object)์˜ค๋Š˜์€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ๋ฐฐ์—ด์— ๋Œ€ํ•ด ์•Œ์•„๋ณผ๊ฒŒ์š”.โ€‹๋ณ€์ˆ˜์—๋Š” 1๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋งŒ ์ €์žฅ ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ํ•˜๋‚˜์˜ ์ €์žฅ์†Œ์— ์ €์žฅํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ• ๊นŒ์š”? ๋ฐฐ์—ด ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•ด ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฐฐ์—ด์„ ์„ ์–ธํ•˜๋ฉด ์•„๋ž˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ ๊ฐ๊ฐ์˜ ๋ฐ์ดํ„ฐ๊ฐ€ ๋‚˜๋ˆ„์–ด์ง„ ์ €์žฅ์†Œ์— ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค.,  ๊ฐ ์ €์žฅ์†Œ๋Š” ์ธ๋ฑ์Šค ๋ฒˆํ˜ธ(๋ฒˆ์ง€์ˆ˜)๊ฐ€ ๋ถ€์—ฌ๋ฉ๋‹ˆ๋‹ค. ์ธ๋ฑ์Šค ๋ฒˆํ˜ธ๋Š” 0๋ฒˆ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.  โœ… 1. ๋ฐฐ์—ด (Array)์„ ์„ ์–ธํ•˜๋Š” 3๊ฐ€์ง€ ๋ฐฉ๋ฒ• 1. Array ์ƒ์„ฑ์ž๋กœ ๋ฐฐ์—ด ์ƒ์„ฑ 12. Array ์ƒ์„ฑ์ž๋กœ ๋ฐฐ์—ด ์ƒ์„ฑ 23. ๋ฆฌํ„ฐ๋Ÿด(๋Œ€๊ด„ํ˜ธ) ์‚ฌ์šฉํ•˜์—ฌ ๋ฐฐ์—ด ์ƒ์„ฑ 1-1. Array ์ƒ์„ฑ์ž๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐฐ์—ด ์ƒ์„ฑํ•˜๊ธฐ 1let ์ฐธ์ดˆ ๋ณ€์ˆ˜ = new Array();์ฐธ์กฐ๋ณ€์ˆ˜[0..
โœ… ๋ฌธ์ œ์ •์ˆ˜ N์„ ์ž…๋ ฅ๋ฐ›์•„ N*N ๋ฐฐ์—ด์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆซ์ž๋ฅผ ์ €์žฅํ•˜๊ณ  ์ถœ๋ ฅํ•˜์‹œ์˜ค. โœ… ์ถ”๋ก  ๊ณผ์ •์ด์ฐจ์› ๋ฐฐ์—ด์— ์ด์ค‘ํฌ๋ฌธ์„ ์จ์„œ ์ˆซ์ž๋ฅผ ์ €์žฅํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค.์ˆซ์ž๊ฐ€ 1์”ฉ ์ฆ๊ฐ€ํ•˜๋Š” ๋ฐฐ์—ด ์นธ์˜ ์ธ๋ฑ์Šค ๋ฒˆํ˜ธ๋ฅผ ์ ์–ด ๋ณด๋ฉด,[0][0] => [1][0] => [2][0] => [3][0] => [4][0][0][1] => [1][1] => [2][1] => [3][1] => [4][1][0][2] => [1][2] => [2][2] => [3][2] => [4][2][x,y] ์ผ ๋•Œy๊ฐ€ 0์ผ๋•Œ x๋Š” 0,1,2,3,4 ๋กœ ๋ณ€ํ•œ๋‹ค.y๊ฐ€ 1์ผ๋•Œ x๋Š” 0,1,2,3,4 ๋กœ ๋ณ€ํ•œ๋‹ค.y๊ฐ€ 2์ผ๋•Œ x๋Š” 0,1,2,3,4๋กœ ๋ณ€ํ•œ๋‹ค.์ฆ‰ ์ด์ค‘ํฌ๋ฌธ์—์„œ ๋ฐ”๊นฅํฌ๋ฌธ์˜ i๊ฐ€ y(์—ด)์ด ๋˜๊ณ ์•ˆ์ชฝ ํฌ๋ฌธ์˜ j๊ฐ€ x(ํ–‰)์ด ๋œ๋‹ค. ์ˆซ์ž๋ฅผ 1์”ฉ ์ฆ๊ฐ€ ํ•ด์ฃผ..
โœ… ๋ฌธ์ œ๋‘ ๊ฐœ์˜ ์ •์ˆ˜๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋ฐ›์•„ ์•ž์˜ ์ •์ˆ˜๊ฐ€ ๋’ค์˜ ์ •์ˆ˜๋กœ ๋‚˜๋ˆ„์–ด์ง€๋Š”์ง€๋ฅผ ํŒ๋ณ„ํ•˜๋Š” ๋ฉ”์†Œ๋“œ isDivide()๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”.์ด ๋•Œ, ๋‚˜๋ˆ„์–ด์ง€๋ฉด true, ๋‚˜๋ˆ„์–ด์ง€์ง€ ์•Š์œผ๋ฉด false๋ฅผ ๋ฐ˜ํ™˜ํ•จโœ… ์ฝ”๋“œpublic class Main { public static void main(String[] args) { int num1 = 10; int num2 = 2; boolean result = isDivide(num1, num2); System.out.println("๊ฒฐ๊ณผ ํ™•์ธ : " + result); } public static boolean isDivide(int num1, int num2) { return num1 % num2 == 0; }} ์ž๋ฐ”์—์„œ ๋ฉ”์†Œ๋“œ ๋งŒ๋“ค ๋•Œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ!! โ˜…ma..
โœ… ๋ฌธ์ œ8์นธ ํฌํ‚ค์˜ ๋ฐฐ์—ด์„ ์„ ์–ธํ•˜๊ณ  ๋žœ๋ค์ˆ˜๋กœ ์ดˆ๊ธฐํ™” ํ•œ ํ›„ ๊ฐ€์žฅ ํฐ ์ˆ˜์™€ ์ž‘์€ ์ˆ˜๋ฅผ ๊ฐ๊ฐ ์ถœ๋ ฅํ•˜์‹œ์˜ค. โœ… ์ถ”๋ก  ๊ณผ์ •- Java์—์„œ ๋žœ๋ค ์ˆ˜๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” java.util.Random ํด๋ž˜์Šค๋‚˜ Math.random() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.๋žœ๋ค์ˆ˜๋ฅผ ๋‚œ์ˆ˜๋ผ๊ณ ๋„ ํ•œ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” java.util.Random ํด๋ž˜์Šค์™€ newํ‚ค์›Œ๋“œ๋กœ ์ƒ์„ฑ ๊ฐ€๋Šฅํ•˜๋‹ค.- ๋žœ๋ค์ˆ˜๋ฅผ ๋‹ด์•„ ์ค„ 8์นธ์งœ๋ฆฌ ๋ฐฐ์—ด์„ ์ƒ์„ฑํ•œ๋‹ค. - ๊ทธ๋ฆฌ๊ณ  ์ตœ์†Œ๊ฐ’๊ณผ ์ตœ๋Œ€๊ฐ’์„ ๋‹ด์•„์ค„ intํ˜• ๋ณ€์ˆ˜ ๋‘ ๊ฐœ๋ฅผ ์„ ์–ธํ•œ๋‹ค. (int mim, max ์„ ์–ธ)- ๋ฐ˜๋ณต๋ฌธ for์„ ๋Œ๋ ค์„œ ๋žœ๋คํ•œ ์ˆ˜๋ฅผ 8๊ฐœ ์ƒ์„ฑํ•˜๋ฉด์„œ ๋ฐฐ์—ด ์ธ๋ฑ์Šค 0๋ฒˆ๋ถ€ํ„ฐ 7๋ฒˆ๊นŒ์ง€ ๋‹ด์•„ ์ค€๋‹ค.-  ์ž๋ฐ”์—์„œ ๋ฐฐ์—ด์„ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•˜๋Š” ๋ฉ”์„œ๋“œ๋Š” java.util.Arrays ํด๋ž˜์Šค์˜ sort() ๋ฉ”์„œ๋“œ์ด๋‹ค. ์—ฌ๊ธฐ์„œ..
์ธ์ ˆ๋ฏธ์˜€๋˜๊ฒƒ
๐Ÿ’ซMy Tech Blog
์ƒ๋‹จ์œผ๋กœ