# 顺序排列【数组】。

4

5 5 5 5

4 4 4 4

3 3 3 3

1 1 1 1

1 1 1 1

3 3 3 3

4 4 4 4

5 5 5 5

``````3
1 2 3
4 5 6
1 1 1``````

``````1 1 1
1 2 3
4 5 6
``````

``````#include<stdio.h>
int main()
{
int i,j,k,n,average[100],flag[100],map[100][100],sum=0,temp;
scanf("%d",&n);
for(i=0;i<n;i++)
{
sum=0;
for(j=0;j<n;j++)
{
scanf("%d",&map[i][j]);
sum+=map[i][j];
}
average[i]=sum/n;
flag[i]=i;
}
for(i=0;i<n;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(average[k]>average[j])
k=j;
temp=average[k];
average[k]=average[i];
average[i]==temp;

temp=flag[k];
flag[k]=flag[i];
flag[i]=temp;
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d",map[flag[i]][j]);
if(j!=n-1)
printf(" ");
}
printf("\n");
}
return 0;
}``````

``````#include<stdio.h>
int main()
{
int i,j,k,n,average[100],flag[100],map[100][100],sum=0,temp;
scanf("%d",&n);
for(i=0;i<n;i++)
{
sum=0;
for(j=0;j<n;j++)
{
scanf("%d",&map[i][j]);
sum+=map[i][j];
}
average[i]=sum/n;
flag[i]=i;
}
for(i=0;i<n;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(average[k]>average[j])
k=j;
temp=average[k];
average[k]=average[i];
average[i]==temp;

temp=flag[k];
flag[k]=flag[i];
flag[i]=temp;
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d",map[flag[i]][j]);
if(j!=n-1)
printf(" ");
}
printf("\n");
}
return 0;
}``````