#include void main() { int mat1[3][3],ma…
Anonymous - Jan 2, 2015
#include
void main()
{
int mat1[3][3],mat2[3][3],i ,j;
static int k=0;
printf(“Enter the values for the matrix \n”);
for(i=0;i<3;i++)
{
printf("\n”);
for(j=0;j<3;j++)
{
scanf("%d”,&mat1[i][j]);
}
}
printf(“Printing the given matrix”);
for(i=0;i<3;i++)
{
printf("\n”);
for(j=0;j<3;j++)
{
printf("%d “,mat1[i][j]);
}
}
printf(“Rotating the given matrix by 90 degrees”);
for(i=2;i>=0;–i)
{
// printf("\n”);
for(j=0;j<3;j++)
{
mat2[j][k]=mat1[i][j];
}
k=k+1;
}
printf(“Printing the rotated matrix “);
printf("\n”); printf("\n”); printf("\n”);
for(i=0;i<3;i++)
{
printf("\n”);
for(j=0;j<3;j++)
{
mat1[i][j]=mat2[i][j];
printf("%d “,mat1[i][j]);
}
}
}
Thanks for sharing. What I love the most about this post is the visual aspect of it, you really spent some time illustrating what rotating matrices meant in a very understandable set of images.
keep on the good work
Thanks andreea. :)
Good program thanks..
Here is my simple code for rotation of matrix by 90 degrees