编写C语言程序实现矩阵的转置

**#include 
#include 
#include 

void fun (int array[3][3])
{
  int i,j,temp[3][3];
  for(i=0;i<3;i++)
  {
      for(j=0;j<3;j++)
      {
          temp[i][j]=array[j][i];
          }
      }

      for(i=0;i<3;i++)
  {
      for(j=0;j<3;j++)
      {
          array[i][j]=temp[i][j];
          }
      }



}
int main()
{
  FILE *wf;
  int i,j;
  int array [3][3]={{100,200,300},{400,500,600},{700,800,900}};
  system("CLS");
  for (i=0;i<3;i++)
     {for (j=0;j<3;j++)
          printf("%7d ",array[i][j]);
      printf("\n ");
     }
  fun(array);
  printf("Converted array:\n ");
  for (i=0;i<3;i++)
     { for (j=0;j<3;j++)
          printf("%7d ",array[i][j]);
       printf("\n ");
     }   
/******************************/
  wf=fopen("out.dat","w");
  for (i=0;i<3;i++)
     { for (j=0;j<3;j++)
          fprintf(wf,"%7d ",array[i][j]);
       fprintf(wf,"\n");
     }   
  fclose(wf);
/*****************************/
return 0;
}
**

你可能感兴趣的:(C-C++)