using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SelectionSort : MonoBehaviour {
int[] res=new int[] {0,10,9,54,86,6,79};
void Start () {
F (res);
}
void F(int[] a){
int[] b = a;
int min,Temp = 0;
for (int i = 0; i < b.Length - 1; i++) {//最好一个不用排
min = i;
for (int j = i + 1; j < b.Length; j++) {
if (b [min] > b [j]) {
Temp = b [min];
b [min] = b [j];
b [j] = Temp;
min = j;
}
}
}
foreach (int c in b)
GetComponent<Text> ().text += c.ToString ()+" ";
}
}
C# 选择排序
最新推荐文章于 2023-09-01 15:50:39 发布