冒泡排序

package main

import (
    "fmt"
)

func main() {
    a := [...]int{1, 3, 6, 4, 8, 0, 6}
    fmt.Println(a)

    num := len(a)
    for i := 0; i < num; i++ {
        for j := i + 1; j < num; j++ {
            if a[i] < a[j] {
                temp := a[i]
                a[i] = a[j]
                a[j] = temp

            }
        }
    }
    fmt.Println(a)
}

 

posted @ 2017-10-31 22:39  Erick-LONG  阅读(215)  评论(0编辑  收藏  举报