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

How to connect to VPS with Private Key on Mac OS

1. Use the cd command to navigate to the directory where your private key file is stored. For example, if your private key is in the Downlo...