C/Visual C - urge ayuda borland c++ p.f.

 
Vista:

urge ayuda borland c++ p.f.

Publicado por julio (1 intervención) el 09/10/2005 23:54:54
Hola a todos,estoy haciendo el siguiente programa pero me marca error en el modulo inserta_antes() y la verdad es que no lo puedo encontrar,si alguien me puede ayudar se lo agradeceré bastante.

Saludos...

#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<ctype.h>

typedef struct NODOS{
int dato;
NODOS* liga;
}NODO;
NODO* p;
NODO* q;
NODO* t;

int bandera=0;

void menu();
void crea_inicio();
void recorre_lista();
void inserta_inicio();
void inserta_final();
void elimina_inicio();
void elimina_final();
void inserta_antes();
void inserta_despues();

void main(){
menu();
}

void menu()
{
int op;
cout<<"***** MENU *****"<<endl;
cout<<"* *"<<endl;
cout<<"* 1.- Crea Inicio * "<<endl;
cout<<"* 2.- Recorre Lista *"<<endl;
cout<<"* 3.- Inserta Inicio *"<<endl;
cout<<"* 4.- Inserta Final *"<<endl;
cout<<"* 4.- Elimina Inicio *"<<endl;
cout<<"* 6.- Elimina Final *"<<endl;
cout<<"* 7.- Inserta Antes *"<<endl;
cout<<"* 8.- Inserta Después *"<<endl;
cout<<"* 9.- Salir *"<<endl;
cout<<"* *"<<endl;
cout<<"***** UABC *****"<<endl<<endl;
cout<<"Eliga Opción-> ";
cin>>op;
if (op<1){
clrscr();
cout<<"ERROR : Opción No Existe !"<<endl<<endl;
cout<<"Presione Cualquier Tecla Para Regresar"<<endl;
getch();
clrscr();
menu();
}
if (op==1){
clrscr();
crea_inicio();
}
if (op==2){
clrscr();
recorre_lista();
}
if (op==3){
clrscr();
inserta_inicio();
}
if (op==4){
clrscr();
inserta_final();
}
if (op==5){
clrscr();
elimina_inicio();
}
if (op==6){
clrscr();
elimina_final();
}
if (op==7){
clrscr();
inserta_antes();
}
if (op==8){
clrscr();
inserta_despues();
}
if (op>9){
clrscr();
cout<<"ERROR : Opción No Existe !"<<endl<<endl;
cout<<"Presione Cualquier Tecla Para Regresar"<<endl;
getch();
clrscr();
menu();
}
}

void crea_inicio(){
clrscr();
if (bandera==1){
cout<<"Inicio Creado Exitosamente !"<<endl<<endl;
cout<<"Presione Cualquier Tecla para Regresar -> ";
getch();
clrscr();
menu();
}
else{
NODO* q;
char resp='s';
p=(NODO*)malloc(sizeof(NODO));
cout<<"Inserte Dato P: -> ";
cin>>p->dato;
p->liga=NULL;
do{
q=(NODO*)malloc(sizeof(NODO));
cout<<"Inserte Dato Q: -> ";
cin>>q->dato;
q->liga=p;
p=q;
cout<<"¿Desea Seguir Capturando? (s/n) : ";
cin>>resp;
tolower(resp);
}
while(resp=='s');
}
bandera=1;
}

void recorre_lista(){
clrscr();
if (bandera==0){
cout<<"Error : EL Inicio No Ha Sido Creado !"<<endl<<endl;
cout<<"Presione Cualquier Tecla para Regresar -> ";
getch();
clrscr();
menu();
}
else{
q=p;
do{
cout<<"Nodo Con Dato -> "<<q->dato;
q=q->liga;
}
while(q!=NULL);
getch();
}
}

void inserta_inicio(){
if (p==NULL){
clrscr();
cout<<"Error : EL Inicio No Ha Sido Creado !"<<endl<<endl;
cout<<"Presione Cualquier Tecla para Regresar -> ";
getch();
clrscr();
menu();
}
else{
q=(NODO*)malloc(sizeof(NODO));
cout<<"Inserte Dato Q: -> ";
cin>>q->dato;
q->liga=p;
p=q;
}
}

void inserta_final(){
clrscr();
if (bandera==0){
cout<<"Error : EL Inicio No Ha Sido Creado !"<<endl<<endl;
cout<<"Presione Cualquier Tecla para Regresar -> ";
getch();
clrscr();
menu();
}
else{
t=p;
do{
t=t->liga;
}
while(t->liga!=NULL);
q=(NODO*)malloc(sizeof(NODO));
cout<<"Inserte Dato Q: -> ";
cin>>q->dato;
q->liga=NULL;
t->liga=q;
}
}

void elimina_inicio(){
q=p;
if (q->liga !=NULL){
p=q->liga;
}
else{
p=NULL;
free(q);
}
}

void elimina_final(){
if (p->liga==NULL){
free(p);
p=NULL;
}
else{
q=p;
}
while(q->liga !=NULL){
t=q;
q=q->liga;
}
t->liga=NULL;
free(q);
}

void inserta_antes(){
q=p;
bandera=1;
while(q^.informacion != ref)&&(bandera==1){
if (q^.liga != NULL){
t=q;
q=q^.liga;
}
else{
bandera=0;
}
}
if (bandera==1){
x=(NODO*)malloc(sizeof(NODO));
x->informacion=dato;

if (r==q){
x->liga=p;
p=x;
}
else{
t->liga=x;
x->liga=q;
}
}
else{
cout<<"Error : No Existe Referencia !"<<endl<<endl;
cout<<"Presione Cualquier Tecla Para Regresar -> ";
getch();
clrscr();
menu();
}
}

}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder