selectionSort_test

2022-12-14 浏览 (755)

selectionSort_test.go 源码

package sort

import (
	"fmt"
	"math/rand"
	"testing"
	"time"
)

func TestSelectionSort(t *testing.T) {
	//只有一个数据时能否正常运行
	one := []int{1}
	selectionSort(one)
	fmt.Println(one)

	//只有两个数据时能否正常运行
	two := []int{3, 1}
	selectionSort(two)
	fmt.Println(two)

	//多个数据时是否正常运行
	var data []int
	rand.Seed(time.Now().Unix())

	for i := 0; i < length; i++ {
		data = append(data, rand.Intn(1000))
	}

	selectionSort(data)
	fmt.Println(data)
}

你可能感兴趣的文章

bubbleSort

bubbleSort_test

bucket_sort

  • 所属分类: 后端技术
  • 本文标签: 技术
  • 版权声明: 本文链接 https://seaxiang.com/blog/b60fa46d39ef48909bd1bdae78edb975