SWIFT
[SWIFT] Coding Test Practice Day 1
HiroDaegu
2022. 11. 8. 13:58
728x90
SMALL
https://school.programmers.co.kr/
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
두수의 합
import UIKit
func solution(_ num1:Int, _ num2:Int) -> Int {
guard (num1 >= -50000 && num1 <= 50000), (num2 >= -50000 && num2 <= 50000) else {
return -110000
}
let res = num1 + num2
return res
}
solution(2, 3)
solution(100, 2)
두수의 차
import UIKit
func solution(_ num1:Int, _ num2:Int) -> Int {
guard (num1 >= -50000 && num1 <= 50000), (num2 >= -50000 && num2 <= 50000) else {
return -110000
}
let res = num1 - num2
return res
}
solution(2, 3)
solution(100, 2)
두수의 곱
func solution(_ num1:Int, _ num2:Int) -> Int {
guard (num1 >= 0 && num1 <= 100), (num2 >= 0 && num2 <= 100) else {
return -1
}
let res = num1 * num2
return res
}
solution(3, 4)
solution(27, 19)
몫 구하기
func solution(_ num1:Int, _ num2:Int) -> Int {
guard (num1 >= 0 && num1 <= 100), (num2 >= 0 && num2 <= 100) else {
return -1
}
let res = num1 / num2
return res
}
solution(10, 5)
solution(7, 2)
728x90
LIST