作业帮 > 综合 > 作业

c语言二维数组排序给定一个10*10的矩阵a,编一程序实现a[i1][j1]

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/11/07 16:39:02
c语言二维数组排序
给定一个10*10的矩阵a,编一程序实现
a[i1][j1]
#include<stdio.h>
int main()
{
 int a[100]={12,35,36,45,88,77,99,14,123,321,
             78,98,58,52,54,56,575,59,15,222,
             111,222,333,444,555,666,777,888,999,101,
              22,33,44,55,66,75,48,49,94,91,93,
             1,2,3,4,5,6,10,7,8,9,85,86,84,46,
             145,146,147,148,149,150,154,156,157,
            168,665,169,167,125,123,124,126,127,
             49,995,458,645,198,197,196,194,129,556,
             213,214,215,219,216,228,227,225,226,
            445,446,447,448,449,450,452,453};
 int b[10][10];
 int i,j,k,e;
 for(i=0;i<100;i++)
  for(j=0;j<100-i;j++)
  {
   if(a[j]>a[j+1])
   {e=a[j];a[j]=a[j+1];a[j+1]=e;}
  }
 k=0;
 for(i=0;i<10;i++)
  for(j=0;j<10;j++)
  {b[i][j]=a[k];k++;}
 for(i=0;i<10;i++)
 { for(j=0;j<10;j++)
   printf("%-4d",b[i][j]);
 printf("\n");}
 printf("\n");
 return 0;
}是这样吧?希望能帮助你!(望采纳)