Ver Mensaje Individual
  #4 (permalink)  
Antiguo 13/06/2010, 14:43
Avatar de Mercality
Mercality
 
Fecha de Ingreso: junio-2010
Mensajes: 19
Antigüedad: 13 años, 10 meses
Puntos: 0
Respuesta: Definir tamaño de una matriz

He hecho lo que me dices, el programa compila. Pero me salta error de que "ha dejado de funcionar, buscando solucion al problema" Que sucede ahora?
Código C:
Ver original
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <conio.h>
  4.  
  5. main() {
  6.        int f,c;
  7.        int *mat[f][c];
  8.        int i,j,k=1,a=0,b=0,d=0,e=0,valor_dinamico;
  9.        printf("Tamaño del vector");
  10.        scanf("%d",&valor_dinamico);
  11.        mat[f][c] = (int *)malloc(valor_dinamico*sizeof(int));
  12.        
  13.         printf("Introduzca la edad de las 16 personas para clasificarlas en niños, jovenes y adultos.\n\n");
  14.        
  15.      for (i=0;i<f;i++)  {
  16.          
  17.          for (j=0;j<c;j++)  {
  18.              
  19.                  printf("Introduzca la edad de la persona numero %d\n",k);
  20.                  scanf ("%d", &mat[i][j]);
  21. system("cls");
  22.                if (k>=1){
  23.                k=k+1;
  24.                }  
  25.             if((int)mat[i][j] <= 13) {
  26.             a=a+1;
  27.             }    
  28.             if((int)mat[i][j] >= 14 && (int)mat[i][j] <=18) {
  29.             b=b+1;
  30.             }    
  31.             if((int)mat[i][j] >=19 && (int)mat[i][j] <=50) {
  32.             d=d+1;
  33.             }
  34.             if((int)mat[i][j] > 51) {
  35.             e=e+1;
  36.             }            
  37.          }
  38.      }
  39.        printf("Cantidad de niños: %d\n", a);
  40.        printf("Cantidad de jovenes: %d\n",b);
  41.        printf("Cantidad de Adultos: %d\n",d);
  42.        printf("Cantidad de viejos: %d\n",e);
  43.        getch();    
  44. }