elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  LISTA SIMPLE
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: LISTA SIMPLE  (Leído 2,678 veces)
m87

Desconectado Desconectado

Mensajes: 3


Ver Perfil
LISTA SIMPLE
« en: 4 Junio 2010, 16:28 pm »

HOLA,ESTOY TRATANDO DE HACER ALGO BASICO, NO ME SALE,RECIEN ESTOY APRENDIENDO, PORQUE ME PARACE Q EN EL BUCLE WHILE(RESP!='N')AL ULTIMO SALE LA PREG "DESEA...",PERO DEBAJO DE ESO YA APARECE "LU"....LE FALTA UN CORCHETE? Y TAMBIEN COMO HAGO PARA QUE MUESTRE LA LISTA?AYUDA.GRACIAS
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>


struct fecha
{
char dia,mes,año;
};
struct alumno
{
int lu;
long int dni;
char apellido[20];
char nombre[20];
char carrera[25];
int edad;
struct fecha ing;
struct alumno*sig;
};
void DarAlta();
void MostrarDatos();

void main ()

{
int op=0;
while (op!=3)
{

printf("====Menu====\n\n");
printf("1-Dar de Alta\n");
printf("2-Mostar Datos\n");
printf("3-Salir\n");
scanf("%d",&op);
switch(op)
{
case 1:DarAlta();break;
case 2:MostrarDatos();break;

}
}
}
void DarAlta ()
{
char resp='s';
while(resp!='n')
{
struct alumno*aux;
struct alumno*inicio=NULL;
struct alumno*nuevo=((struct alumno*)malloc(sizeof(struct alumno)));
printf("INGRESE LOS DATOS:\n");
printf("lu:\n");
scanf("%d",&nuevo->lu);
printf("DNI:\n");
scanf("%d",&nuevo->dni);
printf("Apellido:\n");
scanf("%s",nuevo->apellido);
printf("nombre:\n");
scanf("%s",nuevo->nombre);
printf("carrera:\n");
scanf("%s",nuevo->carrera);
printf("edad:\n");
scanf("%d",&nuevo->edad);
printf("fecha de ingreso:\n");
printf("dia\n");
scanf("%d",nuevo->ing.dia);
printf("mes:\n");
scanf("%d",nuevo->ing.mes);
printf("a¤o:\n");
scanf("%d",nuevo->ing.año);
nuevo->sig=NULL;
if (inicio==NULL)
{
inicio=nuevo;
}
else
aux=inicio;
if (aux->lu>nuevo->lu)
{
nuevo->sig=aux;
inicio=nuevo;
}
else
{
while (aux->sig!=NULL & nuevo->lu>=aux->sig->lu)
{
aux=aux->sig;
}
nuevo->sig=aux->sig;
aux->sig=nuevo;
}
printf("Desea ingresar mas datos\n");
scanf("%c",&resp);
}
}

void MostrarDatos ()
{
struct alumno*inicio;
struct alumno*aux;
int i;
i=0;
aux=inicio;
while (aux!=NULL)
{
printf("%d",aux->lu);
printf("%d",aux->dni);
printf("%s",aux->apellido);
printf("%s",aux->nombre);
printf("%s",aux->carrera);
printf("%d",aux->edad);
printf("%d",aux->ing.dia);
printf("%d",aux->ing.mes);
printf("%d",aux->ing.año);
aux=aux->sig;
i++;
}
if (i==0)
printf("La lista esta vacio");
}



En línea

Littlehorse
All the world's a stage
Moderador
***
Desconectado Desconectado

Mensajes: 2.714


Nie Dam Sie


Ver Perfil WWW
Re: LISTA SIMPLE
« Respuesta #1 en: 5 Junio 2010, 05:31 am »

La verdad no te entendí demasiado sobre cual es el error, lo que si veo es que tu código tiene varios errores. Te remarco algunos:

Código
  1. #include <conio.h>

Librería no estándar, no la necesitas para nada.

Código
  1. void main ()

main siempre debe devolver un entero. int main().

En cuanto al resto, usa la etiqueta GeSHI para poner código, de esta forma:

[code=c]codigo[/code]


En cuanto a la idea general en la implementación de listas, te dejo este link. Léelo entero, seguro te aclara el panorama.

Saludos!


En línea

An expert is a man who has made all the mistakes which can be made, in a very narrow field.
[D4N93R]
Wiki

Desconectado Desconectado

Mensajes: 1.646


My software never has bugs. Its just features!


Ver Perfil WWW
Re: LISTA SIMPLE
« Respuesta #2 en: 5 Junio 2010, 05:41 am »

Lilhorse como haces para poner las etiquetas GeSHI y que se vean? xD
En línea

Littlehorse
All the world's a stage
Moderador
***
Desconectado Desconectado

Mensajes: 2.714


Nie Dam Sie


Ver Perfil WWW
Re: LISTA SIMPLE
« Respuesta #3 en: 5 Junio 2010, 05:45 am »

[nobbc][code=c]codigo[/code][/nobbc]
 ;D
En línea

An expert is a man who has made all the mistakes which can be made, in a very narrow field.
[D4N93R]
Wiki

Desconectado Desconectado

Mensajes: 1.646


My software never has bugs. Its just features!


Ver Perfil WWW
Re: LISTA SIMPLE
« Respuesta #4 en: 5 Junio 2010, 05:48 am »

Se me había olvidado!! gracias!! :D  ;-) ;-)
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
AYUDA ORDENAR LISTA SIMPLE[C]
Programación C/C++
HRSLASH 0 9,114 Último mensaje 23 Abril 2011, 04:22 am
por HRSLASH
Lista circular simple (LCS)
Programación C/C++
Cpp 1 2,146 Último mensaje 11 Diciembre 2014, 01:50 am
por engel lex
Lista simple -- Error
Programación C/C++
eduardo1012 0 1,509 Último mensaje 17 Noviembre 2016, 03:19 am
por eduardo1012
ayuda lista simple imprecion de datos
Programación C/C++
jorgecotrinax 9 2,796 Último mensaje 1 Octubre 2019, 01:39 am
por K-YreX
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines