码迷,mamicode.com
首页 > 其他好文 > 详细

zuoye

时间:2018-10-18 10:51:15      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:while   int   lis   style   code   ===   clu   space   for   

#include<bits/stdc++.h>
using namespace std;
struct node
{
    int date;
    node *next;
    node()
    {
        date=0;
        next=NULL;
    }
};
node head;
void build_list()
{
    cout<<"??ê?è?á′±í3¤?è"<<endl;
    int n; cin>>n;
    node *p=&head;
    for(int i=1;i<=n;i++)
    {
        if(p->next==NULL)
        {
            p->next=new node;
        }
        p=p->next;
        cin>>p->date;
        p->next=NULL;
    }
}
node *f=&head;
void DFS(node *p)
{
    if(p->next==NULL)
    {
        f->next=p;
        f=f->next;
        f->next=NULL;
        return ;
    }
    node *q=p;
    DFS(p->next);
    f->next=q;
    f=f->next; //cout<<"----////"<<f->date<<endl;
    f->next=NULL;

}
void destroy()
{

}
int main()
{
    build_list();
    node *p=&head;
    while(p->next!=NULL)
    {
        cout<<"===";
        p=p->next;
        cout<<p->date<<endl;
    }
    cout<<"-------------------------"<<endl;
    p=&head;
    p=p->next;
    DFS(p);
    p=&head;
    int i=1;
    while(p->next!=NULL)
    {
        i++; if(i==10) break;
        cout<<"===";
        p=p->next;
        cout<<p->date<<endl;
    }
}

 

zuoye

标签:while   int   lis   style   code   ===   clu   space   for   

原文地址:https://www.cnblogs.com/Andromeda-Galaxy/p/9808303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!