Ví dụ 1
func make_20(x: Int, y: Int) -> Bool { if x + y == 20 || x == 20 || y == 20 { return true } else { return false } }
program that accept two integer values and return true if one of them is 20 or if their sum is 20.
Ví dụ 2:
func test_num(x: Int, y: Int) -> Bool {
if x > 0 && y < 0
{
return true
}
else if x < 0 && y > 0
{
return true
}
else if x < 0 && y < 0
{
return true
}
else
{
return false
}
}
program to accept two integer values and return true if one is negative and one is positive. Return true only if both are
No comments:
Post a Comment