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
沒有留言:
張貼留言