题解:
cpp
#include<iostream>
#include<vector>
int main(){
int n,m,count=0;
std::cin>>n>>m;
std::vector<std::vector<int>> a(n,std::vector<int>(n,0));
for(std::vector<std::vector<int>>::iterator row=a.begin();row!=a.end();++row){
for(std::vector<int>::iterator col=row->begin();col!=row->end();++col){
*col=++count;
}
}
std::vector<std::vector<int>> b=a;
//旋转公式用数学坐标推导即可,假设待旋转点为x0,y0,中心点为x,y,即可推导旋转之后的坐标通式
for(int i=0;i!=m;++i){
int x,y,r,z;
std::cin>>x>>y>>r>>z;
for(int j=x-1-r;j<=x-1+r;++j){
for(int k=y-1-r;k<=y-1+r;++k){
if(z==0) b[k-y+x][x+y-2-j]=a[j][k];
else b[y+x-k-2][j-x+y]=a[j][k];
}
}
a=b;
}
for(std::vector<std::vector<int>>::iterator row=b.begin();row!=b.end();++row){
for(std::vector<int>::iterator col=row->begin();col!=row->end();++col){
std::cout<<*col<<" ";
}
std::cout<<std::endl;
}
return 0;
}
结果: