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

Fix Macbook touchbar not working

To reset Touch Bar on MacBook Pro, you need to restart the Touch Bar and Control Strip by running these two commands in Terminal: 'sudo...