Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/11/2012, 08:17
n00b17
 
Fecha de Ingreso: noviembre-2012
Mensajes: 9
Antigüedad: 11 años, 5 meses
Puntos: 0
Matriz: orden de impresión

Hola, me gustaría que me ayudaran con este código:
Crear un programa que lea los datos así

4 7 1 3 5
2 0 6 9 7
3 1 2 6 4

Y los escriba así
4 2 3
7 0 1
1 6 2
3 9 6
5 7 4

Hasta ahora llevo esto:

Código C:
Ver original
  1. #include<stdio.h>
  2.  
  3. void main(){
  4.  
  5. int i,j, f, c, o;
  6. int mat[3][5]={
  7.                 {4,7,1,3,5},
  8.                 {2,0,6,9,7},
  9.                 {3,1,2,6,4}
  10.               };
  11. int ord[o];
  12. int matb[5][3];
  13.  
  14.  
  15.  
  16.     printf("La matriz es: \n");
  17. for(i=0;i<3;i++){
  18.     printf("\n");
  19.     for(j=0;j<5;j++){
  20.         printf("%4d |", mat[i][j]);
  21.         }
  22.  
  23. }
  24. o=0;
  25. for(i=0;i<3;i++){
  26.     for(j=0;j<5;j++){
  27.     ord[o]=mat[i][j];
  28.  
  29.     }
  30. }
  31. o=0;
  32. for(f=0;f<5;f++){
  33.     for(c=0;c<3;c++){
  34.     matb[f][c]=ord[o];
  35. }
  36.  
  37.  
  38.  
  39. }
  40. for(f=0;f<5;f++){
  41.     printf("\n");
  42.     for(c=0;c<3;c++){
  43.         printf("%4d |", matb[f][c]);
  44.     }
  45.  
  46. }
  47. }

Pero se me crashea el programa.
Les quedaré agradecido.