6 * Structure declaration
8 typedef struct _jugador jugador
;
16 typedef struct _futbol futbol
;
21 * Here goes the distinct fields
25 typedef struct _basket basket
;
30 * Here goes the distinct fields
35 typedef struct _deporte deporte
;
42 int anotaciones_favor
;
43 int anotaciones_contra
;
55 get_equipo(deporte
*equipo
)
62 switch ( equipo
->num_deporte
)
66 printf("[Nombre equipo],[victorias],[derrotas],[goles a favor]"
67 ",[goles en contra] : ");
71 printf("[Nombre equipo],[victorias],[derrotas],[anotaciones a favor]"
72 ",[anotaciones en contra] : ");
81 equipo
->nombre
= strtok(tmp
, ",");
82 sscanf(strtok(NULL
, ","), "%d", &equipo
->victorias
);
83 sscanf(strtok(NULL
, ","), "%d", &equipo
->derrotas
);
84 sscanf(strtok(NULL
, ","), "%d", &equipo
->anotaciones_favor
);
85 sscanf(strtok(NULL
, ","), "%d", &equipo
->anotaciones_contra
);
91 switch ( equipo
->num_deporte
)
102 printf("[Nombre jugador estrella] : ");
104 , equipo
->estrella
.nombre
111 get(deporte
**equipos
)
114 get_equipo(*equipos
),equipos
++;
120 get_win(deporte
**equipos
)
122 deporte winner
= **equipos
;
126 if( (*equipos
)->victorias
> winner
.victorias
)
139 alloc_mem(int LIM
, int num_deporte
)
141 deporte
**tmp
= malloc(sizeof(void *)*(LIM
+1));
145 tmp
[i
] = malloc(sizeof(deporte
))
146 , tmp
[i
]->num_deporte
= num_deporte
147 , tmp
[i
]->tipo_deporte
= malloc(sizeof(futbol
));
158 printf("Numero de equipos futbol : ");
160 deporte
**equipos_futbol
= alloc_mem(LIM
, 0);
163 printf("Numero de equipos basket : ");
165 deporte
**equipos_basket
= alloc_mem(LIM
, 1);
171 deporte winner
= get_win(equipos_futbol
);
173 printf("El ganador de futbol es : %s con %d victorias.\n", winner
.nombre