Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Summation Function
//swift 3.0.2 //import Fundation //函式 func pro_summation(x: Int) { var total = 0 for i in 1...x{ total = total + i } print("1加到\(x)總和:\(total)") } //程式主體 var x = 1 print("請在空白處輸入大於1的數值") if let input_x = readLine(){ if let x = Int(input_x){ if(x>1){ pro_summation(x: x)//for Swift 3 //pro_summation(x)//for Swift 2.2 }else{ print("輸入值請大於1") } } }else{ print("輸入值為空") }
run
|
edit
|
history
|
help
0
factorial
Условия и циклы
Сложение и массивы
test
F
card_seat_taken_kuy09
Ok
swift Fibonacci Series
Сложение и массивы (копия)
Swift 3 components vs regex