Banner

My Tech Blog (๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ)

โœ… ๋ฌธ์ œํ•™์ƒ๋“ค์˜ ์„ฑ์  ์ •๋ณด๊ฐ€ ๋ฌธ์ž์—ด๋กœ ์„ ์–ธ๋˜์–ด ์žˆ์„ ๋•Œ, ๊ฐ ์„ฑ์  ๋ณ„ ํ•™์ƒ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜์‹œ์˜ค.  โœ… ์ฝ”๋“œ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() ๋ฉ”์„œ๋“œ์ด๋‹ค. ์—ฌ๊ธฐ์„œ..
๋ฐฐ์—ด์€ ์ผ๋ จ์˜ ๋™์ผํ•œ ์œ ํ˜•์˜ ๋ฐ์ดํ„ฐ ์š”์†Œ๋ฅผ ๋ณด์œ ํ•˜๋Š” ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์ด๋ฉฐ, ์ž๋ฐ”์—์„œ ๋งค์šฐ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์ž๋ฐ”์—์„œ ๋ฐฐ์—ด์„ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์—ฌ๋Ÿฌ ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์ธ ๋ฐฉ๋ฒ•๋“ค์ž…๋‹ˆ๋‹ค. 1. ๋ฐฐ์—ด ์ƒ์„ฑํ•˜๊ธฐ 1) ๋ฐฐ์—ด ๋ฆฌํ„ฐ๋Ÿด๋กœ ์ƒ์„ฑํ•˜๊ธฐ ๋ฐฐ์—ด์„ ์ง์ ‘ ์ •์˜ํ•˜๊ณ  ๊ฐ’์„ ํ• ๋‹นํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. int[] numbers = {1, 2, 3, 4, 5}; String[] names = {"John", "Doe", "Alice"}; 2) new ํ‚ค์›Œ๋“œ๋กœ ์ƒ์„ฑํ•˜๊ธฐ new ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐฐ์—ด์„ ๋™์ ์œผ๋กœ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. int[] numbers = new int[5]; // ํฌ๊ธฐ๊ฐ€ 5์ธ ์ •์ˆ˜ ๋ฐฐ์—ด ์ƒ์„ฑ String[] names = new String[3]; // ํฌ๊ธฐ๊ฐ€ 3์ธ ๋ฌธ์ž์—ด ๋ฐฐ์—ด ์ƒ์„ฑ 3) ๋ฐฐ์—ด์˜ ..
์ธ์ ˆ๋ฏธ์˜€๋˜๊ฒƒ
'๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (48 Page)
์ƒ๋‹จ์œผ๋กœ