zoukankan      html  css  js  c++  java
  • Day7 functionType

     

                                  **Day 8

                                  **Function Style

     

    func add(a:Int,b:Int) -> Int

    {

        return a+b

    }

     

    add(5, b: 6)

     

    let anotherAdd:(Int,Int)-> Int = add

     

    anotherAdd(1,1)

     

    var a = 5,b=1

     

    swap(&a, &b)

    a

    b

     

    func changeScores1(inout scores:[Int])

    {

        for i in 0..<scores.count

        {

            scores[i] = Int( Double(scores[i]) / 150.0 * 100.0 )

            

        }

    }

     

    var scores1 = [1,5,1,5,4,2,3]

    changeScores1(&scores1)

    scores1

     

     

     

    func changeSorts(inout number:[Int])

    {

     

        for i in 0..<number.count

        {

            number[i] = Int(number[i]*10)

        }

        

    }

     

    var arr = [55,6,1,88]

     

    changeSorts(&arr)

     

    arr

     

     

     

    var a = 9

     

    var b = sqrt(Double(a))

     

    func binarySystem(number:Int) -> String

    {

        var resultValue : String = ""

        

        var result = number

        

        while result > 0

        {

        

            resultValue = String(result%2) + resultValue

            

            result /= 2

            

            print(result)

            

        }

        

        return resultValue

        

    }

     

     

    binarySystem(6)

     

     

     

     

  • 相关阅读:
    ASP.NET MVC简介
    jQuery
    C#webform LinQ
    webform LinQ
    C# WebForm内置对象2+Repeater的Command
    C#WebForm内置对象
    JavaScricp
    Webform 内置对象 Session对象、Application全局对象,ViewState
    Webform 内置对象 Response对象、Request对象,QueryString
    WebForm复杂控件
  • 原文地址:https://www.cnblogs.com/tony0571/p/5373897.html
Copyright © 2011-2022 走看看