<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16441" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Buenas noches a todos,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>    Les comento que estoy dando mis 
primeros pasos en C++, el tema es que no consigo armar un nodo con una 
estructura de datos....lo plantíe de esta manera (En turbo C++ 3.0, ya que en 
ese compilador lo pide la facu).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Bueno, marque en <FONT 
color=#0000ff><STRONG>azul</STRONG></FONT> la parte del código que tengo 
dudas.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Gracias por vuestros comentarios y/o 
sugerencia.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Luciano</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Nodo 
*************************************************************************************************************************************************************************</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>class nodo {<BR> private:<BR> tipodato 
valor;                                        
    //Nodo Simple<BR> int 
m_iNumFactura;                                 
  //Nodo Factura<BR> char m_cPendiente;<BR> nodo 
*pnProximo;<BR> nodo *pnAnterior;<BR> public:<BR><FONT 
color=#0000ff> <STRONG>nodo(tipodato valor) {valor=0; pnProximo=NULL; 
pnAnterior=NULL;}</STRONG></FONT><BR><STRONG> <FONT color=#0000ff>nodo(int 
m_iNumFactura,char m_cPendiente) {m_iNumFactura=0;m_cPendiente='n'; 
pnProximo=NULL; pnAnterior=NULL;}</FONT></STRONG><BR> void set_prox(nodo 
*prox);<BR> void set_ant (nodo *ant);<BR> void set_val (tipodato 
val);<BR><STRONG> <FONT color=#0000ff>void set_val (int Factura, char 
Tipo);</FONT></STRONG><BR> nodo * es_ant();<BR> nodo * 
es_prox();<BR> tipodato es_val();<BR> int es_factura();<BR> char 
es_pendiente();<BR> };<BR>void nodo::set_prox (nodo 
*prox)<BR> {pnProximo=prox;}<BR>void nodo::set_ant (nodo 
*ant)<BR> {pnAnterior=ant;}<BR>void nodo::set_val (tipodato 
val)<BR> {valor=val;}<BR>void nodo::set_val (int Factura, char 
Tipo)<BR> {m_iNumFactura=Factura;m_cPendiente=Tipo;}<BR>nodo* 
nodo::es_ant()<BR> {return pnAnterior;}<BR>nodo* 
nodo::es_prox()<BR> {return pnProximo;}<BR>tipodato 
nodo::es_val()<BR> {return valor;}<BR>int 
nodo::es_factura()<BR> {return m_iNumFactura;}<BR>char 
nodo::es_pendiente()<BR> {return m_cPendiente;}<BR>Pila 
******************************************************************************************************************************************************************************************</FONT></DIV>
<DIV><FONT face=Arial size=2>class pila<BR>{<BR> private:<BR> int 
tope;<BR> nodo *actual;<BR> public:<BR> pila() 
{tope=0;actual=NULL;}<BR><FONT color=#0000ff><STRONG> int meter (tipodato 
a);</STRONG><BR><STRONG> int meter (int Factura, char 
Tipo);</STRONG></FONT><BR> tipodato sacar ();<BR><STRONG><FONT 
color=#0000ff> void sacarFactura (int *iFactura,char *cTipo 
);</FONT></STRONG><BR> int esvacia ();<BR> int 
cantelem();<BR>    void vaciar();<BR> };</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>int pila::meter (tipodato 
a)                 
//devuelve 0 si no pudo, 1 si pudo<BR> {nodo *p,*q;<BR><STRONG><FONT 
color=#0000ff> p=new nodo(a);</FONT></STRONG><BR> if (!p) 
{cout<<"Error nodo";<BR>    return 
0;<BR>    } //controlar punt nulo<BR> if 
(actual==NULL)<BR>  {actual=p;<BR>   
actual->set_ant(NULL);<BR>   <FONT 
color=#0000ff><STRONG>actual->set_val 
(a);}</STRONG></FONT><BR> else<BR>  {q=actual;<BR>   
actual=p;<BR>   actual->set_ant(q);<BR>   
actual->set_val (a);}<BR> tope++;<BR> return 1;<BR> } //fin 
meter<BR><STRONG><FONT color=#0000ff>int pila::meter (int iFactura, char 
cTipo)</FONT></STRONG>              
//devuelve 0 si no pudo, 1 si pudo<BR> {nodo *p,*q;<BR> <STRONG><FONT 
color=#0000ff>p=new nodo(iFactura, cTipo);</FONT></STRONG><BR> if (!p) 
{cout<<"<FONT 
color=#ff0000><STRONG>Error  Nodo";    Aca se 
pincha</STRONG></FONT><BR> return 
0;<BR> }                                                                                    
 //controlar punt nulo<BR> if 
(actual==NULL)<BR>  {actual=p;<BR>   
actual->set_ant(NULL);<BR>   <FONT 
color=#0000ff><STRONG>actual->set_val 
(iFactura,cTipo);}</STRONG></FONT><BR> else<BR>  {q=actual;<BR>   
actual=p;<BR>   actual->set_ant(q);<BR>   
actual->set_val (iFactura, cTipo);}<BR> tope++;<BR> return 
1;<BR> } //fin meter<BR>void pila::sacarFactura (int *iFactura,char *cTipo 
)              
//devuelve tipodato<BR> {nodo 
*p,*q;                                                                 
  //Puntero p=actual - q=anterior<BR> if 
(actual==NULL)<BR>  {cout<<"Pila 
vacia";}<BR> else<BR>  {q=actual->es_ant();<BR>   
*iFactura=actual->es_factura();<BR>   
*cTipo=actual->es_pendiente();<BR>   p=actual;<BR>   
delete p;<BR>   actual=q;<BR>   tope 
--;}<BR> }</FONT></DIV>
<DIV><FONT face=Arial 
size=2>Codigo**********************************************************************************************************************************************************************************************</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>int m,n,iValor,iElem;<BR></FONT><FONT face=Arial 
size=2>void membrete ()<BR>{  clrscr();<BR>   gotoxy (10, 6); 
printf ("3-Dada una pila de facturas ordenadas en forma creciente por 
nro");<BR>   gotoxy (10, 8); printf ("de factura,pasar a una cola las 
j primeras facturas a pagar.");<BR>   gotoxy (10,10); printf("Imprimir 
la Pila y la Cola resultante.");<BR>   gotoxy (5, 12); printf 
("*********************** MENU DE OPCIONES 
**************************");<BR>   for(int 
i=12;i<28;i++)<BR>   {gotoxy (5, i); printf ("*"); gotoxy (71, i); 
printf ("*");}<BR>   gotoxy (6, 14); printf ("  1-Cargar 
Facturas  - Tipo Pila       
");<BR>   gotoxy (6, 16); printf ("  2-Ordenar 
Facturas                   
");<BR>   gotoxy (6, 18); printf ("  3-Visualizar 
Facturas                
");<BR>   gotoxy (6, 20); printf ("  4-Visualizar Facturas 
Pendientes     ");<BR>   gotoxy (6, 22); printf 
("  5-Visualizar Cola de 
Pagos           
");<BR>   gotoxy (6, 24); printf ("  6-Transferir Pila a Cola de 
Pagos    ");<BR>   gotoxy (6, 26); printf ("  
0-Salir                              
");<BR>   gotoxy (5, 28); printf 
("*******************************************************************");<BR>   
gotoxy (10, 30);printf ("Opci¢n : ");<BR>   cin>>m;<BR>}<BR>void 
cargapila (pila 
*p)                                         
//Cargar pila<BR>{<BR>  int iFactura;<BR>  char cTipo, 
q='n';<BR>  clrscr();<BR>  while (q!='s'){<BR>  cout<<"\n 
Ingrese la Factura : ";<BR>  cin>>iFactura;<BR>  cout<<"\n 
Se encuentra pendiente de Pago (s/n) ? ";<BR>  cin>>cTipo;<BR>  
p->meter(iFactura,cTipo);<BR>  cout<<"\nDesea salir (s/n) 
?";<BR>  cin>>q;<BR>  }<BR>}<BR>void mostrarpila (pila 
*p)<BR> {pila *w;<BR>  w=new pila;<BR>  int 
iFactura,c=0;<BR>  char cTipo;<BR>  clrscr();<BR>  gotoxy 
(10, 4); printf("*********Pila de Facturas********");<BR>  gotoxy (10, 6); 
printf("---------------------------------");<BR>  gotoxy (10, 8); 
printf("    Factura    |   
Pendiente     ");<BR>     if 
(p->esvacia())<BR>     {cout<<"La pila no tiene 
facturas \n";}<BR>     while (!p->esvacia()) 
//<BR> <STRONG><FONT color=#0000ff> { 
p->sacarFactura(&iFactura,&cTipo);</FONT></STRONG><BR>   
w->meter(iFactura, cTipo);<BR>   gotoxy (12+c, 10); 
printf("",iFactura);<BR>   gotoxy (12+c, 16); 
printf("",cTipo);<BR>   c=c+2;<BR>  }<BR>  while 
(!w->esvacia())<BR>   {p->meter(iFactura,cTipo);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>   }   //Se carga la 
pila<BR>  getch();<BR>  delete w;<BR>}<BR>void mostrarcola (cola 
*c)<BR> {cola *w;<BR>  w=new cola;<BR>  tipodato a;<BR>  
clrscr();<BR>  if (c->esvacia())<BR>  cout<<"La cola no tiene 
elementos \n";<BR>  while (!c->esvacia())<BR>  
{a=c->sacar();<BR>   w->meter(a);<BR>   
cout<<"Elemento "<<(c->cantelem()+1)<<": 
"<<a<<"\n";<BR>  }<BR>  while (!w->esvacia()) 
{c->meter(w->sacar());}   //Se carga la pila<BR>  
getch();<BR>  delete w;<BR>}<BR>void transferir (pila *p,cola 
*c){<BR> tipodato a;<BR> clrscr();<BR>  while (!p->esvacia()) 
//<BR>  {a=p->sacar();<BR>   c->meter(a);<BR>  
}<BR>  cout<<"\n Pila transferida a Cola...";<BR>  
getch();<BR> }<BR>/************************************************************************************/</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>int main()<BR>{<BR> pila *p;<BR> cola 
*c;<BR> tipodato a,b;<BR> p=new pila;<BR> c=new cola;<BR>while 
(1){<BR>clrscr();<BR>membrete();<BR>  switch (m)<BR>    
{<BR>  <STRONG> case 
1: {cargapila(p);break;}</STRONG><BR>   <STRONG>case 2: 
{mostrarpila(p);break;}</STRONG><BR><BR>    }<BR>//fin 
switch<BR>if (m==0)break;<BR>}//fin while<BR>gotoxy (35, 
45);printf("\Fin");<BR>getch();<BR>return 0;<BR>};</FONT></DIV></BODY></HTML>