fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct {
  4. int arr[4][4];
  5. } FourByFour;
  6.  
  7. FourByFour rotate(FourByFour m) {
  8. FourByFour D;
  9. for(int i = 0; i < 4; i ++ ){
  10. for(int n = 0; n < 4; n++){
  11. D.arr[i][n] = m.arr[n][3 - i];
  12. }
  13. }
  14. return D;
  15. }
  16.  
  17. int main(void) {
  18. FourByFour S = {.arr = { { 1, 4, 10, 3 }, { 0, 6, 3, 8 }, { 7, 10 ,8, 5 }, { 9, 5, 11, 2} } };
  19. FourByFour r = rotate(S);
  20. for(int i=0; i < 4; i ++ ){
  21. for(int n=0; n < 4; n++){
  22. printf("%d ", r.arr[i][n]);
  23. }
  24. printf("\n");
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
3 8 5 2 
10 3 8 11 
4 6 10 5 
1 0 7 9