View Code of Problem 45

#include<stdio.h>
int main()
{
	int i,j,n,temp;
	int a[10][10];
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
		{
			scanf("%d", &a[i][j]);
		}
	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++)
		{
			if (j == 0) 
			{
				printf("%d", a[i][j]);
			}
			if (j != 0)
			{
				printf(" %d", a[i][j]);
			}
		}
		printf("\n");
	}
}

Double click to view unformatted code.


Back to problem 45