![](https://i-blog.csdnimg.cn/blog_migrate/52d8091ee3c5241bfdcebe8bdcc10401.png)
旋转正方形矩阵
Here is the C++ program to print upperhalf and lowerhalf triangle of a square matrix.
这是C ++程序,用于打印方矩阵的上半部和下半部三角形。
#include<iostream>
using namespace std;
int main()
{
int a[10][10],i,j,m;
cout<<"Enter size of the Matrix(min:3,max:5):";
cin>>m;
cout<<"\nEnter the Matrix row wise:\n";
for(i=0;i<m;i++)
for(j=0;j<m;++j)
cin>>a[i][j];
cout<<"\n\n";
for(i=0;i<m;++i)
{
for(j=0;j<m;++j)
{
if(i<j)
cout<<a[i][j]<<" ";
else
cout<<" ";
}
cout<<"\n";
}
cout<<"\n\n";
for(i=0;i<m;++i)
{
for(j=0;j<m;++j)
{
if(j<i)
cout<<a[i][j]<<" ";
else
cout<<" ";
}
cout<<"\n";
}
return 0;
}
Output
输出量
Enter size of the Matrix(min:3,max:5):3
输入矩阵的大小(最小:3,最大:5):3
Enter the Matrix row wise: 1 2 3 4 5 6 7 8 9
明智地输入矩阵行: 1 2 3 4 5 6 7 8 9
2 3 6
2 3 6
4 7 8
4 7 8
翻译自: https://www.thecrazyprogrammer.com/2011/12/c-program-to-print-upperhalf-and.html
旋转正方形矩阵