Created
October 25, 2016 13:13
-
-
Save kiras0518/0504563ae863bae7254018e2710f1c02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
語法作業1,改寫function | |
*/ | |
func calNumber(row:Int, column:Int) -> Int //2個參數Int傳入值 回傳一個Int | |
{ | |
var total = 0 | |
for i in 0...row | |
{ | |
for j in 0...column where i%2 == 1 | |
{ | |
total += i*j | |
print(total) | |
} | |
} | |
return total | |
} | |
calNumber(row: 7, column: 7) | |
/* | |
語法作業1,格子總和,除了列數。=行數格子 | |
*/ | |
func calNumber1(row:Int, column:Int) -> Int //2個參數Int傳入值 回傳一個Int | |
{ | |
var total = 0 | |
for i in 0...row | |
{ | |
for j in 0...column where j < i | |
{ | |
total += i*j | |
print(total) | |
} | |
} | |
return total | |
} | |
calNumber1(row: 7, column: 7) | |
/* | |
寫個函式 | |
華氏轉成攝氏 | |
*/ | |
func t(F:Int) -> Int { | |
var c = 0 | |
c = (F - 32) * 5/9 | |
return c | |
} | |
t(F: 80) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment