fork download
  1. #include <stdio.h>
  2.  
  3. int main (void) {
  4. int matriz[3][3], rot[3][3];
  5. for (int i = 0; i < 3; i++) {
  6. for (int j = 0; j < 3; j++) {
  7. printf("Digite o valor da matriz[%d][%d]: ", i + 1, j + 1);
  8. scanf("%d", &matriz[i][j]);
  9. }
  10. }
  11. for (int i = 0; i < 3; i++) {
  12. printf("\n");
  13. for (int j = 0; j < 3; j++) printf(" %d ", matriz[i][j]);
  14. }
  15. for (int i = 0; i < 3; i++) for (int j = 2; j >= 0; j--) rot[i][j] = matriz[j][2 - i];
  16. printf("\nMATRIZ 90º");
  17. for (int i = 0; i < 3; i++) {
  18. printf("\n");
  19. for (int j = 0; j < 3; j++) printf(" %d ", rot[i][j]);
  20. }
  21. }
  22.  
  23. //https://pt.stackoverflow.com/q/391441/101
Success #stdin #stdout 0s 9424KB
stdin
1
2
3
4
5
6
7
8
9
stdout
Digite o valor da matriz[1][1]: Digite o valor da matriz[1][2]: Digite o valor da matriz[1][3]: Digite o valor da matriz[2][1]: Digite o valor da matriz[2][2]: Digite o valor da matriz[2][3]: Digite o valor da matriz[3][1]: Digite o valor da matriz[3][2]: Digite o valor da matriz[3][3]: 
 1  2  3 
 4  5  6 
 7  8  9 
MATRIZ 90º
 3  6  9 
 2  5  8 
 1  4  7