開発環境
- OS X Mavericks - Apple(OS)
- Xcode 6.0 Beta
- Swift (プログラミング言語)
Practical Programming: An Introduction to Computer Science Using Python 3 (Pragmatic Programmers) (Paul Gries (著)、Jennifer Campbell (著)、Jason Montojo (著)、Lynn Beighley (編集)、Pragmatic Bookshelf)のChapter 6(A Modular Approach to Program)、6.6(Exercises) 3-a, b.をSwiftで考えてみる。
6.6(Exercises) 3-a, b.
コード(Xcode)
main.swift
// // main.swift // exercise // // Created by kamimura on 8/9/14. // Copyright (c) 2014 kamimura. All rights reserved. // import Foundation func average(num1:Double, num2:Double) -> Double { return (num1 + num2) / 2 } let a:Int = 10 let b:Int = 20 let c:Double = 15.0 println(average(Double(a), Double(b)) == c) let d:Double = 2.5 let e:Double = 3.0 let f:Double = 2.75 println(average(d, e) == f)
入出力結果(Console Output)
true true Program ended with exit code: 0
0 コメント:
コメントを投稿