using UnityEngine;
using System.Collections;
public class chena : MonoBehaviour {
void Start () {
int t;
int j = 0;
string s = "";
int [] aa = new int[10]{1,2,3,4,5,6,7,8,9,10};
for (int i=0; i<10; i++) {
s+=aa[i];
}
for (int i=9; i>aa.Length/2; i--)
{
t=aa[j];
aa[j]=aa[i];
aa[i]=t;
j++;
}
for (int i=0; i<10; i++) {
s+=aa[i];
}
Debug.Log (s);
}
void Update () {
}
}
或者
- public int[] str = {22,123,32,52,64,875,1,23,4,3};
- public string s;
- void Start () {
- for (int i=0; i<5; i++) {
- int temp;
- temp=str[i];
- str[i]=str[9-i];
- str[9-i]=temp;
- }
- for (int i=0; i<10; i++) {
- s+=str[i]+" ";
- }
- print (s);
- }