View Code of Problem 45

#include<stdio.h>
int main()
{
	int n;
	int value;
	scanf("%d",&n);
	int a[n][n];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i<=j)
			{
				value=a[i][j];
				a[i][j]=a[j][i];
				a[j][i]=value;
//				t=i;
//				i=j;
//				j=t;
			}
		}
	}
	int count=0;
	for(int i=0;i<n;i++)	
	{
		for(int j=0;j<n;j++)
		{
			printf("%d",a[i][j]);
			count++;
			if(count%n!=0) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 45