Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // listas.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <stdlib.h>
- #include <stdio.h>
- #define TAM_NOMBRE 50
- /*******************************FICHA***********************************************/
- typedef struct ficha_datos
- {
- int edad;
- float peso;
- char nombre[TAM_NOMBRE];
- }Ficha;
- void llenar_ficha(Ficha *apFicha)
- {
- int i=0;
- apFicha->edad = rand()%100;
- apFicha->peso = 1+rand()%300;
- for(i=0;i<rand()%TAM_NOMBRE;i++)
- apFicha->nombre[i]='a'+rand()%('z'-'a'+1);
- apFicha->nombre[i]='\0';
- }
- void imprimir_ficha(Ficha *apFicha)
- {
- int i=0;
- printf("Datos de Ficha\n");
- printf("Nombre: "); puts(apFicha->nombre);
- printf("Edad: %d\n", apFicha->edad);
- printf("Peso: %.2f\n", apFicha->peso);
- }
- /*****************************LISTA**********************************************/
- typedef struct elemento_de_lista
- {
- Ficha datos;
- struct elemento_de_lista *ANT, *SIG;
- }Elemento;
- Elemento* inicializar_lista(Elemento *lista) // inserta un elemento en la lista vacia
- {
- Elemento *nuevo=(Elemento *)malloc(sizeof(Elemento));
- llenar_ficha(&(nuevo->datos));
- nuevo->ANT=NULL;
- nuevo->SIG=NULL;
- imprimir_ficha(&nuevo->datos);
- return nuevo;
- }
- /*a partir de un elemento de lista, encontrar su último elemento*/
- Elemento* obtener_fin(Elemento *aux)
- {
- while(aux->SIG!=NULL)
- aux=aux->SIG;
- return aux;
- }
- /*a partir de un elemento de lista, encontrar su primer elemento*/
- Elemento* obtener_ini(Elemento *aux)
- {
- while(aux->ANT!=NULL)
- aux=aux->ANT;
- return aux;
- }
- insertar_medio()
- {
- Elemento *nuevo;
- }
- int main()
- {
- Ficha elemento;
- llenar_ficha(&elemento);
- imprimir_ficha(&elemento);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment