View Code of Problem 45

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	int temp,i,j,N,a[100][100];;
	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=i;j<N;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 == N - 1))
			{
				printf("%d",a[i][j]);
			}
			else
			{
				printf("%d ",a[i][j]);
			}
		}
		printf("\n");}
  return 0;
}

Double click to view unformatted code.


Back to problem 45