zoukankan      html  css  js  c++  java
  • go排序-冒泡排序

    package main
    
    import "fmt"
    
    func main() {
    	var list  = []int{0,-3,234,234,12,435,43,2,23,2}
    	bubbleSort(list)
    	fmt.Println(list)
    }
    
    func bubbleSort(list []int)  {
    	n := len(list)
    	
    	for i :=0;i<n-1;i++{
    		for j:=0;j<n-1-i;j++{
    			if list[j] > list[j+1]{
    				list[j+1],list[j] = list[j],list[j+1]
    			}
    		}
    	}
    }
    

      

    GOROOT=/usr/local/go #gosetup
    GOPATH=/home/deepin/go #gosetup
    /usr/local/go/bin/go build -o /tmp/___go_build_main_go /home/deepin/go/test1/main.go #gosetup
    /tmp/___go_build_main_go
    [-3 0 2 2 12 23 43 234 234 435]

    Process finished with the exit code 0

  • 相关阅读:
    makefile
    xcode
    centos
    debug
    服务器开发
    socket
    xcode
    调用cpp库更基本
    nodejs cpp动态库
    html5图片裁剪法--
  • 原文地址:https://www.cnblogs.com/brady-wang/p/15039102.html
Copyright © 2011-2022 走看看