#include<iostream>
using namespace std;
int main()
{
int m=3;//长
int n=3;//宽
int k = 0;
int num[3][3];
for (int i = 0; i < m; i++) {
for (int j=0; j < n; j++) {
num[i][j] = 0;
k++;
num[i][j] = k;
cout << num[i][j];
}cout << endl;
}
//初始化外带赋值
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
int temp = 0;
temp = num[i][j];
num[i][j] = num[j][i];
num[j][i] = temp;
if (i == j ) { break; }
}cout << endl;
//对角互换
}for (int i = 0; i < 3; i++) {
int temp = 0;
temp = num[i][0];
num[i][0] = num[i][2];
num[i][2] = temp;
}
//以j=2为对称轴进行互换
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cout << num[i][j];
}
cout << endl;
}
}
标签:cout,temp,int,旋转,++,num,方阵 From: https://www.cnblogs.com/yiyulhb/p/17541415.html