// Use this for initialization void Start() { int n = 1000; int[] arr = AlgorithmsHelp.generateRandomArray(n, 1, 3); int[] arrcopy = AlgorithmsHelp.CopyIntArray(arr, n); AlgorithmsHelp.testSort("BubbleSort", BubblableSort, arr, n); AlgorithmsHelp.printData(arr); AlgorithmsHelp.testSort("BubbleSort1", BubblableSort1, arrcopy, n); AlgorithmsHelp.printData(arrcopy); }
// Use this for initialization void Start() { // int n = 1000; // //实验1 // int[] arr = AlgorithmsHelp.generateRandomArray (n, 1, n); // int[] sameArr = AlgorithmsHelp.CopyIntArray (arr,n); // AlgorithmsHelp.testSort ("InsertionSort1", InsertionSort1, sameArr, n); // AlgorithmsHelp.printData (sameArr); //// AlgorithmsHelp.testSort ("SelectionSort", SelectSort.SelectionSort,arr,n); //// AlgorithmsHelp.printData (sameArr); // AlgorithmsHelp.testSort ("InsertionSort", InsertionSort, arr, n); // AlgorithmsHelp.printData (arr); //实验2 比较有序数组的,选择排序的超快性 int n = 10000; int[] arr = AlgorithmsHelp.generateNearlyOrderArray(n, 10); int[] sameArr = AlgorithmsHelp.CopyIntArray(arr, n); AlgorithmsHelp.testSort("InsertionSort1", InsertionSort1, arr, n); AlgorithmsHelp.printData(arr); AlgorithmsHelp.testSort("SelectionSort", SelectSort.SelectionSort, sameArr, n); AlgorithmsHelp.printData(sameArr); }
// Use this for initialization void Start() { int[] a = { 3, 9, 8, 7, 6, 5, 4, 3, 2, 1 }; string s = ""; foreach (int num in a) { s += num + " "; } print(s + " "); s = ""; SelectionSort(a, 10); foreach (float num in a) { s += num + " "; } print(s + " "); s = ""; float[] b = { 4.4f, 3.3f, 2.2f, 1.1f }; foreach (var num in b) { s += num + " "; } print(s + " "); s = ""; SelectionSort(b, 4); foreach (var num in b) { s += num + " "; } print(s + " "); // 测试模板函数,传入字符串数组 string[] c = { "D", "C", "B", "A" }; s = ""; foreach (var num in c) { s += num + " "; } print(s + " "); s = ""; SelectionSort(c, 4); foreach (var num in c) { s += num + " "; } print(s + " "); Student[] d = { new Student("D", 90), new Student("C", 100), new Student("B", 95), new Student("A", 95) }; s = ""; foreach (var num in d) { print(num); } SelectionSort(d, 4); foreach (var num in d) { print(num); } int n = 10000; // a = null; // a = AlgorithmsHelp.generateRandomArray (n,1,n); // AlgorithmsHelp.printData (a); // SelectionSort(a,n); // AlgorithmsHelp.printData (a); // a = null; a = AlgorithmsHelp.generateRandomArray(n, 1, n); AlgorithmsHelp.printData(a); AlgorithmsHelp.testSort("SelectionSort", SelectionSort, a, n); AlgorithmsHelp.printData(a); int i = 3; float f = i; }