- using UnityEngine;
- using System.Collections;
- public class pppp : MonoBehaviour {
- public int[] a = {2,3,1,4,6,7,8,9,0};
- // Use this for initialization
- void Start () {
- for(int j=0;j<a.Length;j++){
- for(int i=0;i<a.Length-1;i++){
- if(a[i]<a[i+1]){
- // int n=a[i];
- // a[i]=a[i+1];
- // a[i+1]=n;
- a[i]=a[i]+a[i+1];
- a[i+1]=a[i]-a[i+1];
- a[i]=a[i]-a[i+1];
- }
- }
- }
- foreach(int n in a){
- Debug.Log(n);
- }
- }
- // Update is called once per frame
- void Update () {
- }
- }
Untiy3D------ 冒泡排序与不用第三个变量实现排序
最新推荐文章于 2024-02-01 12:07:37 发布