[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฐฐ์ด ์๋ฅด๊ธฐ, ์ง์ ํ์ ๊ฐ์
๋ฌธ์ 1. ๋ฐฐ์ด ์๋ฅด๊ธฐโ๏ธ ๋ฌธ์ ๋ฐ๋ก ํ๊ธฐ ํด๋ฆญ ๋์ ๋ฌธ์ ํ์ดimport java.util.Arrays;class Solution { public int[] solution(int[] numbers, int num1, int num2) { // Arrays.copyOfRange(๋ฐฐ์ด, start, end)๋ end ์ธ๋ฑ์ค๋ฅผ ํฌํจํ์ง ์์ผ๋ฏ๋ก num2 + 1๋ฅผ ์ฌ์ฉํ์ฌ num2๊ฐ ํฌํจ ๋ ์ ์๋๋ก ์ค์ return Arrays.copyOfRange(numbers, num1, num2 + 1); }} ์คํ ๊ณผ์ ์์....numbers = {1, 2, 3, 4, 5}, num1 = 1, num2 = 3solution.solution(new..
2025. 3. 5.
[241115] ๋ฐฐ์ด์ ํ๊ท ๊ฐ(for๋ฌธ ์ฐ์ตํ๊ธฐ)
1. ๋ฌธ์ ์ ์ ๋ฐฐ์ด numbers๊ฐ ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง๋๋ค. numbers์ ์์์ ํ๊ท ๊ฐ์ returnํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์. 2. ์ ํ ์ฌํญ- 0 ≤ numbers์ ์์ ≤ 1,000- 1 ≤ numbers์ ๊ธธ์ด ≤ 100- ์ ๋ต์ ์์ ๋ถ๋ถ์ด .0 ๋๋ .5์ธ ๊ฒฝ์ฐ๋ง ์
๋ ฅ์ผ๋ก ์ฃผ์ด์ง๋๋ค. 3. ์
์ถ๋ ฅ ์ 4. ๋ด๊ฐ ํผ ์ฝ๋class Solution { public double solution(int[] numbers) { double answer = 0; for(int i=0; i 5. ์ฝ๋ ํด์- {1,2,3,4,5,6,7,8,9,10} ์ ๋ํ ์ฝ๋ ํด์
2024. 11. 15.