7-9

#include<stdio.h>

int main(void)

{

         int i,j,n,temp;

         int a[6][6];

 

         printf("Enter n:");

         scanf("%d",&n);

         for(i=0;i<n;i++)

                   for(j=0;j<n;j++)

                            a[i][j]=i*n+j+1;

                   for(i=0;i<n;i++)

                            for(j=0;j<n;j++)

                                     if(i<=j){

                                               temp=a[i][j];

                                               a[i][j]=a[j][i];

                                               a[j][i]=temp;

                                     }

                                     for(i=0;i<n;i++){

                                               for(j=0;j<n;j++)

                                                        printf("%4d",a[i][j]);

                                               printf("\n");

                                     }

                                     return 0;

}

posted @ 2013-10-06 15:36  zhaoyang16  阅读(97)  评论(0编辑  收藏  举报