using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class 冒泡排序 : MonoBehaviour
{
int[] arr = new int[] { 2, 1, 6, 5, 8, 7, 9 };
public int[] 冒泡Test(int[] arr)//大到小排序
{
for (int i = 0; i < arr.Length; i++)
{
for (int j = 0; j < arr.Length - 1; j++)
{
if (arr[j] < arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
return arr;
}
public void Start()
{
int[] temp = 冒泡Test(arr);
string MaxToMin = "";
for (int i = 0; i < temp.Length; i++)
{
Debug.Log(MaxToMin += temp[i] + "/");
}
}
}
得出结论9/8/7/6/5/2/1