fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // scan data
  5. int R[10],C[10],M;
  6. scanf("%d%d%d",&R[0],&C[0],&M);
  7. int array[10][10][10];
  8. for(int i=0;i<R[0];i++)
  9. for(int j=0;j<C[0];j++)
  10. scanf("%d",&array[0][i][j]);
  11.  
  12. //執行操作
  13. int move[10];
  14. int count;
  15. for(count=0;count<M;count++){
  16. scanf("%d",&move[count]);
  17. if(move[count]==0){ //旋轉
  18. R[count+1]=C[count];
  19. C[count+1]=R[count];
  20. for(int i=0;i<R[count+1];i++)
  21. for(int j=0;j<C[count+1];j++)
  22. array[count+1][i][j]=array[count][R[count]-1-j][i];
  23. }
  24. else{ //翻轉
  25. R[count+1]=R[count];
  26. C[count+1]=C[count];
  27. for(int i=0;i<R[count+1];i++)
  28. for(int j=0;j<C[count+1];j++)
  29. array[count+1][i][j]=array[count][R[count]-1-i][j];
  30. }
  31. }
  32.  
  33. //輸出結果
  34. printf("%d %d\n",R[M],C[M]);
  35. for(int i=0;i<R[M];i++){
  36. for(int j=0;j<C[M];j++)
  37. printf("%d ",array[M][i][j]);
  38. printf("\n");
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5288KB
stdin
3 2 2
3 3
2 1
1 2
0 1
stdout
2 3
2 1 3 
1 2 3