在unity内用c#实现一个数组的倒序输出

//1. 编写程序,把由10个元素组成的一维数组逆序存放再输出。
		
		//string [] array = {"1","2","3","4","5","6","7","8","9","10"};
		int [] array = {1,2,3,4,5,6,7,8,9,10,11};
		for (int i=0; i<array.Length; i++) 
		{
						Debug.Log (array[i]);
		}

		//string n;
		int n;
		//int x = array.Length;
		for (int i=0; i<array.Length/2; i++)
		{
			//x--;
			n=array[i];
			//array[i]=array[x];
			//array[x]=n;
			array[i]=array[array.Length-i-1];
			array[array.Length-i-1]=n;

		}
		for (int i=0; i<array.Length; i++) 
		{
			Debug.Log (array[i]);
		}
		

你可能感兴趣的:(C#,unity,数组倒序)