Golang 冒泡排序
2016-05-08 09:53
465 查看
package main import ( "fmt" ) func main() { //声明一个无序数据 array := [...]int{22, 37, 3, 2, -3, 2, 9, 1, 8888, 337, 271, 1, 27, 371, 381, 37619, 86, 27} //获取数组长度 num := len(array) for i := 0; i < num; i++ { for j := 1; j < num-i; j++ { if array[j-1] > array[j] { array[j-1], array[j] = array[j], array[j-1] //交换两个元素的位置 } } } fmt.Println(array) }
相关文章推荐
- golang学习第一篇 golang简介
- django框架从零开始_007_view以及模版页
- django 模版语法及使用
- django 视图开发与url配置
- HDU 1056 - HangOver
- django
- django 安装
- CodeForces-657A-Bear and Forgotten Tree 3
- Django Mode
- CodeForces 598D Igor In the Museum
- Go语言之异常处理
- Go语言之异常处理
- Beego 1.6+ 错误页面(404,500)自定义重定向
- google gflags 库完全使用
- POJ_2195_Going Home_最小费用最大流
- Golang 中使用多维 map
- GooHong
- go程序性能测量和分析
- HDU 1397 Goldbach's Conjecture
- 拥有属于自己的SVN(Google SVN)[转]