Ver Mensaje Individual
  #5 (permalink)  
Antiguo 18/02/2015, 23:40
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: Vector de punteros

Lo siento pero no ocupas punteros para esta tarea.

Si tu profesor te dice que lo hagas con punteros a fuerza posiblemente es un idiota, porque se me ocurren al menos 5 mejores casos de como utilizar punteros.

Otra cosa, no uses gets mi gcc se estuvo quejando por eso.
Código C:
Ver original
  1. #include<stdio.h>
  2. #define MAX 3
  3. struct DATOS{
  4.  
  5.     char nombre[30];
  6.     int nota;
  7.  
  8. };
  9.  
  10.  
  11. void ingreso(struct DATOS [], int );
  12. void mostrar(struct DATOS [], int );
  13. //void ordenar(* [], int L);
  14.  
  15. void main(){
  16.  
  17.     struct DATOS vec[MAX], aux;
  18.     int i,k;
  19.  
  20.     ingreso(vec,MAX);
  21.  
  22.     //ordenamiento
  23.     for(i=0;i<MAX;i++){
  24.         for(k=0;k<MAX-i-1;k++){
  25.             if(vec[k].nota < vec[k+1].nota){
  26.  
  27.                 aux=vec[k];
  28.                 vec[k]=vec[k+1];
  29.                 vec[k+1]=aux;
  30.             }
  31.         }
  32.     }
  33.  
  34.     mostrar(vec,MAX);
  35.  
  36.  
  37. }
  38.  
  39.  
  40. void ingreso(struct DATOS v[], int L){
  41.  
  42.     int i;
  43.  
  44.     for(i=0;i<L;i++){
  45.  
  46.         printf("\nIngrese nombre: ");
  47.         gets(v[i].nombre);
  48.         printf("\nIngrese nota: ");
  49.         scanf("%d", &v[i].nota);
  50.         getchar();
  51.     }
  52.  
  53. }
  54.  
  55. void mostrar(struct DATOS v[], int L){
  56.  
  57.     int i;
  58.  
  59.     for(i=0;i<L;i++){
  60.  
  61.         printf("\nNombre: %s",v[i].nombre);
  62.         printf("\nNota: %d",v[i].nota);
  63.  
  64.     }
  65.  
  66. }