package main import ("fmt" "math/rand" ) const NUMS = 100 var num [NUMS] int func gen_nums() { rand.Seed(183) for count := 0; count < NUMS; count++ { num[count] = rand.Intn(10000) } } func swap(x *int, y *int) { temp := *x *x = *y *y = temp } func main() { gen_nums() for count1 := 0; count1 < NUMS - 1; count1++ { for count2 := count1 + 1; count2 < NUMS; count2++ { if num[count1] > num[count2] { swap(&num[count1], &num[count2]) } } } for count := 0; count < NUMS; count++ { fmt.Printf("%d\n", num[count]) } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more