fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void) {
  5. int n;
  6. char command[20];
  7. int matrix[150][150];
  8. scanf("%d", &n);
  9. for(int i=0; i< n;i++){
  10. for(int j = 0; j< n; j++){
  11. scanf("%d", &matrix[i][j]);
  12. }
  13. }
  14. scanf("%s", command);
  15. if(command[0] == 'l'){
  16. for(int i=n - 1; i>= 0;i--){
  17. for(int j = 0; j< n; j++){
  18. printf("%d ", matrix[j][i]);
  19. }
  20. printf("\n");
  21. }
  22. }
  23. else if(command[0] == 'r'){
  24. for(int i=0; i<n;i++){
  25. for(int j = n-1; j>=0; j--){
  26. printf("%d ", matrix[j][i]);
  27. }
  28. printf("\n");
  29. }
  30. }
  31. else if(command[0] == 't'){
  32. for(int i=0; i< n;i++){
  33. for(int j = 0; j< n; j++){
  34. printf("%d ", matrix[j][i]);
  35. }
  36. printf("\n");
  37. }
  38. }
  39. else if(command[0] == 'f'){
  40. for(int i=n - 1; i>= 0;i--){
  41. for(int j=n - 1; j>= 0;j--){
  42. printf("%d ", matrix[i][j]);
  43. }
  44. printf("\n");
  45. }
  46. }
  47. return 0;
  48. }
  49.  
Success #stdin #stdout 0.01s 5316KB
stdin
2
1 2
3 4
f
stdout
4 3 
2 1