Go语言实现的冒泡排序 有更新!

    package main
    
    import (
    	"fmt"
    )
    
    func main() {
    	a := [...]int{4, 3, 77, 6, 3, 5}
    	fmt.Println("before sort", a)
    	num := len(a)
    	for i := 0; i < num; i++ {
    		for j := i + 1; j < num; j++ {
    			if a[i] < a[j] {
                           a[i],a[j] = a[j],a[i]
    		}
    	}
    	fmt.Println("after sort", a)
    }
    

    可点击下面的“RUN"来运行:


    本文为风林火山博客原创,转载请注明出处:www.flcoder.com
    validate