Tuesday 9 January 2024

Cấu trúc If

 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

Mức thuế ở Úc từ 07/2024

Chính phủ Úc đã thay đổi các mức thuế suất cho thu nhập cá nhân và các mức thu nhập (được gọi là ‘ngưỡng’) áp dụng những thuế suất này. Việc...