#include <stdio.h>
#define N 3
void print_data(int [][N]);
void convert_data(int [][N]);
int main(int argc, int *argv[])
{
int i,j,temp;
int a[N][N];
printf("please input 9 number:\n");
for (i = 0; i < N; i++)
{
for(j = 0; j < N; j++)
{
scanf("%d",&a[i][j]);
}
}
printf("your input data is :\n");
print_data(a);
convert_data(a);
print_data(a);
system("pause");
return 0;
}
void print_data(int data[][N])
{
int i,j;
for (i = 0; i < N; i++)
{
for (j = 0;j < N; j++)
{
printf("%d ",data[i][j]);
}
printf("\n");
}
printf("\n");
}
void convert_data(int data[][N])
{
int i,j,temp;
for (i = 0; i < N; i++)
{
for (j = i + 1;j < N; j++)
{
temp = data[i][j];
data[i][j] = data[j][i];
data[j][i] = temp;
}
}
}
|