如果数组是一个方阵,可以这样:
for(int i=0;i for(int j=i+1;j { int temp=a[i,j]; a[i,j]=a[j,i]; a[j,i]=temp; }
如果是一个M*N的矩阵的话,就需要重新组织数组了,但是原理差不多