本帖最后由 plglenn12 于 2010-03-12 23:52:41 编辑

解决方案 »

  1.   


    #include<iostream.h>    
       
    struct node    
    {    
        int id;    
         node *N;    
         node *P;    
    };      
       
    void cre(node *&head,node *&rear)    
    {    
         node *p=new node;    
       
         node *v;    
         head=v=p;    
         p->P=NULL;    
         cout<<"id:"<<endl;    
         cin>>p->id;      
       
        while(p->id)    
         {    
             v=p;    
             p=new node;    
             v->N=p;    
             p->P=v;    
             cout<<"id:"<<endl;    
             cin>>p->id;      
         }    
         p->N=NULL;    
         rear=p;    
    }    
       
    void abc(node *p)    
    {    
        while(p)    
             cout<<p->id<<endl,p=p->N;    
    }    
       
    void cba(node *p)    
    {    
        while(p)    
             cout<<p->id<<endl,p=p->P;    
    }    
       
    void main()      
    {      
         node *head,*rear;    
         cre(head,rear);    
         abc(head);    
         cba(rear);    
    }    
    网上瞎找的,免得你背后骂我老猪只会说风凉话。