Bibi's DevLog ๐ค๐
[๋ฐฑ์ค 10101] ์ผ๊ฐํ ์ธ์ฐ๊ธฐ(Swift) ๋ณธ๋ฌธ
ํ๋ก๊ทธ๋๋ฐ/์๊ณ ๋ฆฌ์ฆ ํ์ด Swift
[๋ฐฑ์ค 10101] ์ผ๊ฐํ ์ธ์ฐ๊ธฐ(Swift)
๋น๋น bibi 2022. 12. 14. 11:29- ์ฃผ์ด์ง ๋๋ก ์ถ๋ ฅ์ ๊ตฌํํ๋ฉด ๋๋ ๊ฐ๋จํ ๋ฌธ์ ์ด๋ค.
ํ์ด1 (69100KB, 8ms)
var triangleArray = Array<Int>()
(1...3).forEach { _ in
triangleArray.append(Int(readLine()!)!)
}
if triangleArray.reduce(0, +) == 180 {
if triangleArray[0] == triangleArray[1] && triangleArray[1] == triangleArray[2] {
print("Equilateral")
} else if triangleArray[0] == triangleArray[1] || triangleArray[1] == triangleArray[2] || triangleArray[0] == triangleArray[2] {
print("Isosceles")
} else {
print("Scalene")
}
} else {
print("Error")
}
ํ์ด2
๋ค๋ฅธ ๋ถ๋ค ํ์ด๋ฅผ ๋ณด๋ ๊ณต๊ฐ๋ณต์ก๋๊ฐ ํจ์ฌ ์ ๊ฒ ๋์๊ธธ๋ โ๋๋ ๋ฐฐ์ด์ ์ ์ฐ๊ณ ๋จ์ํ ์ธ๋ฒ ์ ๋ ฅ๋ฐ๊ณ ๊ณ ์ฐจํจ์๋ฅผ ์ ์ฐ๋ฉด ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋ ์ฐ๋ ค๋?โํด์ ๊ทธ๋ ๊ฒ๋ ๋ฐ๊ฟ๋ดค๋๋ฐ, ์ฑ์ ํด๋ด๋ ๊ณต๊ฐ๋ณต์ก๋๊ฐ ๋์ผํ๋ค.
์๋ ๊ณผ ์ฑ์ ๊ธฐ์ค์ด ๋ฌ๋ผ์ง๊ฑธ๊น..?๐ค ๊ถ๊ธํ๋ค..
let x = Int(readLine()!)!
let y = Int(readLine()!)!
let z = Int(readLine()!)!
if x + y + z == 180 {
if x == y && y == z {
print("Equilateral")
} else if x == y || y == z || x == z {
print("Isosceles")
} else {
print("Scalene")
}
} else {
print("Error")
}
'ํ๋ก๊ทธ๋๋ฐ > ์๊ณ ๋ฆฌ์ฆ ํ์ด Swift' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Swift] DFS ์์ ์ ํ์ด (Softeer ์ฅ์ ๋ฌผ ์ธ์ ํ๋ก๊ทธ๋จ) (0) | 2023.01.16 |
---|---|
[๋ฐฑ์ค 10539] ์๋น์ด์ ์์ด (Swift) (0) | 2023.01.11 |
[๋ฐฑ์ค 18312] ์๊ฐ (Swift) (0) | 2022.12.13 |
[์ด์ฝํ ] 4.๊ตฌํ - 2. ์์ค์ ๋์ดํธ (Swift) (0) | 2022.12.13 |
[๋ฐฑ์ค 9501] ๊ฟ์ ์ฐ์ฃผ์ฌํ (Swift) (0) | 2022.12.12 |