package main
import (
"fmt"
"math/rand"
"time"
)
func InitDate(s []int){
rand.Seed(time.Now().Unix())
for i:=0;i
s[i]=rand.Intn(10)
}
}
func Maopao(s []int){
n:=len(s)
for i:=0;i
for j:=0;j
if s[j]>s[j+1]{
s[j],s[j+1]=s[j+1],s[j]
}
}
}
}
func main(){
n:=12
s1:=make([]int,n)
InitDate(s1)
fmt.Printf("排序前:%v\n",s1)
Maopao(s1)
fmt.Printf("排序后:%v\n",s1)
}
网友评论