๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป iOSun
article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] swift ํ˜ธํ…” ๋Œ€์‹ค

๋ฌธ์ œ ์„ค๋ช… ๋ช‡๊ฐœ์˜ ๊ฐ์‹ค์ด ํ•„์š”ํ•œ์ง€ ๊ตฌํ•˜๋Š” ๋ฌธ์ œ ํ•œ ๊ฐ์‹ค์„ ์ด์–ด์„œ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ์ฒญ์†Œ์‹œ๊ฐ„ 10๋ถ„์„ ๋”ํ•ด์•ผ ํ•œ๋‹ค. ๋ฌธ์ œ ํ’€์ด 1. ์˜ˆ์•ฝ ์‹œ์ž‘ ์‹œ๊ฐ„ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค. 2. ์‹œ๊ฐ„์„ ๋ถ„์œผ๋กœ ๊ณ„์‚ฐํ•œ๋‹ค. 10:10 -> 10*60 + 10 = 610 3. ๊ฐ์‹ค ๋ฒˆํ˜ธ๋ฅผ ๋ฐฐ์ •ํ•˜๊ณ  ๋งŒ์•ฝ ๋ฐฐ์ •๋œ ์˜ˆ์•ฝ์‹œ๊ฐ„์˜ ๋๋‚˜๋Š” ์‹œ๊ฐ„+10๋ณด๋‹ค ์˜ˆ์•ฝ ์‹œ์ž‘์‹œ๊ฐ„์ด ๋‚˜์ค‘์ด๋ฉด ๊ทธ ๊ฐ์‹ค์„ ์ด์–ด ์‚ฌ์šฉํ•œ๋‹ค. import Foundation func solution(_ book_time:[[String]]) -> Int { var answer = 0 let bookTime = book_time.sorted(by: {$0[0] < $1[0]}) var bookNum = Array(repeating: 0, count: bookTime.count) // ๊ฐ์‹ค๋ฒˆํ˜ธ..

article thumbnail
[CS ๋ฉด์ ‘ ์งˆ๋ฌธ] ํ”„๋กœ์„ธ์Šค(1)

ํ”„๋กœ์„ธ์Šค์™€ ์Šค๋ ˆ๋“œ์˜ ์ฐจ์ด๋Š” ๋ฌด์—‡์ธ๊ฐ€์š”? ํ”„๋กœ์„ธ์Šค๋ž€ .exe๊ฐ™์€ ์•„์ง ์‹คํ–‰๋˜์ง€ ์•Š์€ ํŒŒ์ผ์„ ํ”„๋กœ๊ทธ๋žจ์ด๋ผ๊ณ  ํ•˜๋Š”๋ฐ ๊ทธ ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰์‹œํ‚ค๋ฉด ํ”„๋กœ์„ธ์Šค๋‹ค. ์ฆ‰ ์ปดํ“จํ„ฐ์—์„œ ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š” ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค. ์Šค๋ ˆ๋“œ๋ž€ ํ”„๋กœ์„ธ์Šค๊ฐ€ ํ• ๋‹น๋ฐ›์€ ์ž์›์„ ์ด์šฉํ•˜๋Š” ์‹คํ–‰ ํ๋ฆ„์˜ ๋‹จ์œ„์ด๋‹ค. ๋‘˜์˜ ํฐ ์ฐจ์ด๋Š” ์Šค๋ ˆ๋“œ๋Š” ์Šค๋ ˆ๋“œ๋ผ๋ฆฌ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๊ณต์œ ํ•˜์ง€๋งŒ ํ”„๋กœ์„ธ์Šค๋Š” ์ž์‹ ์˜ ์ž์›๋งŒ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ๋”ฐ๋ผ์„œ ํ•œ ์Šค๋ ˆ๋“œ๊ฐ€ ์ข…๋ฃŒ๋œ๋‹ค๋ฉด ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ์—๊ฒŒ ์˜ํ–ฅ์„ ๋ผ์น˜์ง€๋งŒ ํ”„๋กœ์„ธ์Šค๋Š” ํ•œ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ข…๋ฃŒ๋˜์–ด๋„ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค์—๊ฒŒ ์˜ํ–ฅ์„ ๋ผ์น˜์ง€ ์•Š๋Š”๋‹ค. ๊ต์ฐฉ์ƒํƒœ๋ž€ ๋ฌด์—‡์ด๋ฉฐ, ๊ต์ฐฉ์ƒํƒœ๊ฐ€ ๋ฐœ์ƒํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์–ด๋–ค ์กฐ๊ฑด์ด ์žˆ์–ด์•ผ ํ•˜๋‚˜์š”? ๊ต์ฐฉ์ƒํƒœ๋ž€ ํ”„๋กœ์„ธ์Šค or ์Šค๋ ˆ๋“œ๋“ค์ด ์„œ๋กœ ํ•„์š”ํ•œ ์ž์›์„ ํ•œ์ •์ ์œผ๋กœ ์„œ๋กœ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ์ด๋‹ค. ๊ต์ฐฉ ์ƒํƒœ ๋ฐœ์ƒ ์กฐ๊ฑด์€ 4๊ฐ€์ง€์ด๊ณ  ๋ชจ๋‘ ์ถฉ์กฑ..

article thumbnail
[Swift Language Guide] ๋ฌธ์ž์—ด๊ณผ ๋ฌธ์ž (Strings and Characters)
Swift Language Guide 2023. 5. 16. 22:15

// ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด์— ํŠน์ˆ˜ ๋ฌธ์ž let sparklingHeart = "\\u{1F496}" // ๐Ÿ’–, Unicode scalar U+1F496 // ๋ฌธ์ž์—ด ๋ณ€๊ฒฝ var variableString = "Horse" variableString += " and carriage" // "Horse and carriage" ๋ฌธ์ž์—ด์€ ๊ฐ’(value) ํƒ€์ž…์ด๋‹ค. ์›๋ณธ์ด ์•„๋‹Œ ์ƒˆ๋กœ์šด ๋ณต์‚ฌ๋ณธ์ด ์ „๋‹ฌ๋œ๋‹ค. ์œ ๋‹ˆ์ฝ”๋“œ (Unicode) ์ธ์ฝ”๋”ฉ, ํ‘œ๊ธฐ, ๊ทธ๋ฆฌ๊ณ  ๋‹ค๋ฅธ ์“ฐ๊ธฐ ์‹œ์Šคํ…œ์—์„œ์˜ ํ…์ŠคํŠธ ํ”„๋กœ์„ธ์‹ฑ์„ ์œ„ํ•œ ๊ตญ์ œ ํ‘œ์ค€์ด๋‹ค. Swift์˜ String ๊ณผ Character ํƒ€์ž…์€ ์œ ๋‹ˆ์ฝ”๋“œ๋ฅผ ์™„๋ฒฝํ•˜๊ฒŒ ์ง€์›ํ•œ๋‹ค. Swift์˜ ๊ธฐ๋ณธ String ํƒ€์ž…์€ ์œ ๋‹ˆ์ฝ”๋“œ ์Šค์นผ๋ผ ๊ฐ’ (Unicode scalar values) ์œผ๋กœ๋ถ€ํ„ฐ ์ƒ์„ฑ var ..

article thumbnail
[Swift Language Guide] ๊ธฐ๋ณธ ์—ฐ์‚ฐ์ž (Basic Operators)
Swift Language Guide 2023. 5. 16. 22:12

๋Œ€์ž… ์—ฐ์‚ฐ์ž (Assignment Operator) if x = y { // ํ‹€๋ฆฐ ๋ฌธ๋ฒ•, ๋Œ€์ž… ์—ฐ์‚ฐ์ž๋Š” ๊ฐ’์„ ๋ฆฌํ„ดํ•˜์ง€ ์•Š์Œ } ์‚ฐ์ˆ  ์—ฐ์‚ฐ์ž (Arithmetic Operators) 1 + 2 // equals 3 5 - 3 // equals 2 2 * 3 // equals 6 10.0 / 2.5 // equals 4.0 ๊ฐ’์ด ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ ๋˜๋Š” ๊ฒƒ์„ ํ—ˆ๋ฝํ•˜์ง€ ์•Š์Œ ๋‚˜๋จธ์ง€ ์—ฐ์‚ฐ์ž (Remainder Operator) -9 % 4 // -9 = (4*-2) + (-1) a = (b x some multiplier) + remainder ๊ณ„์‚ฐ์‹์œผ๋กœ ๋‚˜๋จธ์ง€ ๊ณ„์‚ฐ ๋‹จํ•ญ ๋บ„์…ˆ ์—ฐ์‚ฐ์ž (Unary Minus Operator) & ๋‹จํ•ญ ๋ง์…ˆ ์—ฐ์‚ฐ์ž (Unary Plus Operator) // ๋‹จํ•ญ ๋บ„์…ˆ ์—ฐ์‚ฐ์ž let th..

profile on loading

Loading...