2019年2月19日 星期二

Julia 語言 if敘述語法

Julia 語言 if敘述語法

n = 10
for i=1:n
    println("i = $i")
    if i % 2 == 0
        println("$i, even")
    elseif i == 5
        println("$i")
    else
        println("(^_^)v")
    end
end


輸出結果
$julia main.jl
i = 1
(^_^)v
i = 2
2, even
i = 3
(^_^)v
i = 4
4, even
i = 5
5
i = 6
6, even
i = 7
(^_^)v
i = 8
8, even
i = 9
(^_^)v
i = 10
10, even

沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...