๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ“ ์•Œ๊ณ ๋ฆฌ์ฆ˜/Programmers

(51)
[PGS] Lv.0 (์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ž…๋ฌธ) 3์ผ์ฐจ ๋ฌธ์ œ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๋‚˜๋จธ์ง€ ๊ตฌํ•˜๊ธฐ int solution(int num1, int num2) { int answer = -1; answer = num1 % num2; return answer; } ์ค‘์•™๊ฐ’ ๊ตฌํ•˜๊ธฐ int solution(vector array) { int answer = 0; int len = array.size() + 1; sort(array.begin(), array.end()); answer = array[len / 2 - 1]; return answer; } ์ตœ๋นˆ๊ฐ’ ๊ตฌํ•˜๊ธฐ โœ๐Ÿป ๊ฐ’์„ ๊ตฌํ•ด์•ผํ•˜๋Š”๋ฐ ๋‚˜์˜จ ํšŸ์ˆ˜๋ฅผ ๊ตฌํ•˜๋ฉด์„œ ์‚ฝ์งˆํ•ด์„œ ์ข€ ์˜ค๋ž˜๊ฑธ๋ ธ๋‹ค,.. ์ผ๋‹จ ๋ฐฐ์—ด๋ฌธ์ œ๋Š” ์ •๋ ฌ๋ถ€ํ„ฐ ํ•˜๊ณ  ์‹œ์ž‘ํ•˜๊ธฐ!! โœ๐Ÿป ๊ทธ๋ฆฌ๊ณ  for๋ฌธ 1๋ถ€ํ„ฐ ์‹œ์ž‘ํ• ๋•Œ๋Š” ํ•ญ์ƒ 0์ธ ์˜ˆ์™ธ๋ฅผ ๊ณ ๋ คํ•ด์•ผ ํ•œ๋‹ค int solution(vecto..
[PGS] Lv.0 (์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ž…๋ฌธ) 2์ผ์ฐจ ๋ฌธ์ œ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๋‘ ์ˆ˜์˜ ๋‚˜๋ˆ—์…ˆ // sol 1 int solution(int num1, int num2) { double answer = 0; double mod = 0; mod = modf((num1*1000)/num2, &answer); return (int)answer; } // sol 2 int solution(int num1, int num2) { double answer = (double)num1*1000/num2; return (int)answer; } ์ˆซ์ž ๋น„๊ตํ•˜๊ธฐ int solution(int num1, int num2) { if(num1==num2) return 1; return -1; } ๋ถ„์ˆ˜์˜ ๋ง์…ˆ vector solution(int denum1, int num1, int denum2..
[PGS] Lv.0 (์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ž…๋ฌธ) 1์ผ์ฐจ ๋ฌธ์ œ โœ… 1์›” ๋ชฉํ‘œ : ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๋ ˆ๋ฒจ0 100๋ฌธ์ œ ๋‹ค ํ’€๊ธฐ https://github.com/inthhh/TIL-ps GitHub - inthhh/TIL-ps Contribute to inthhh/TIL-ps development by creating an account on GitHub. github.com ์š”์ฆ˜ ๋งค์ผ TIL ์“ฐ๋ฉด์„œ ๊นƒํ—ˆ๋ธŒ ์ž”๋””์‹ฌ๊ธฐ ์ค‘์ธ๋ฐ, ๋ธ”๋กœ๊ทธ์—๋„ ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์งฌ์งฌ์ด ๋ชฐ์•„์„œ ์˜ฌ๋ ค๋ณผ ์˜ˆ์ •์ด๋‹ค. ๋Š˜ ๊ทธ๋ ‡๋“ฏ ์ง€์‹์„ ๊ณต์œ ํ•˜๋Š” ์ผ์€ ์ฆ๊ฑฐ์šฐ๋‹ˆ๊นŒ!! ๋‘ ์ˆ˜์˜ ํ•ฉ int solution(int num1, int num2) { int answer = -1; answer = num1 + num2; return answer; } ๋‘ ์ˆ˜์˜ ์ฐจ int solution(int num1, int num2) {..

728x90