#15150: C++思路參考


fdhs107_KonChin_Shih (Konchin)

學校 : 桃園市私立復旦高級中學
編號 : 69313
來源 : [140.113.168.124]
最後登入時間 :
2025-05-05 16:44:06

我砍了很多地方,照貼也不會對

不過翻轉跟旋轉可以參考下


int r,c,m;
int arr[(r>c?r:c)][(r>c?r:c)];
bool marr[m];
for(int t=0;t!=m;t++){
if(!marr[m-t-1]){//旋轉
int temp[c][r];
for(int n=0;n!=r;n++)
for(int i=0;i!=c;i++)
temp[i][n]=arr[n][i];
SWAP(r,c);
for(int n=0;n!=r;n++)
for(int i=0;i!=c;i++)
arr[n][i]=temp[n][i];
}//翻轉
int temp[r][c];
for(int n=0;n!=r;n++)
for(int i=0;i!=c;i++)
temp[r-n-1][i]=arr[n][i];
for(int n=0;n!=r;n++)
for(int i=0;i!=c;i++)
arr[n][i]=temp[n][i];
}