Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1126205
  • 博文数量: 241
  • 博客积分: 4385
  • 博客等级: 上校
  • 技术积分: 2383
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-07 23:13
文章分类

全部博文(241)

文章存档

2013年(1)

2012年(8)

2011年(62)

2010年(109)

2009年(61)

分类: C/C++

2009-07-15 15:27:32

#include
using namespace std;
 
typedef struct node
{
    int data;
    struct node *next;
}Node;
 
Node *CreateList()
{
    int i=0;//member's count
    Node *head,*p,*q;
    int temp;
    head=new Node;//creat node:head
 
    while(1)
    {
        cout<<"Please input the data:"<        cin>>temp;
  
        if(temp=0)//if temp=0 then quit while
            break;
  
        p=new Node;
        p->data=temp;
  
        if(++i=1)//only node:head exist
            head->next=p;
        else
            q->next=p;
        q=p;
    }
    q->next=NULL;//end of link
    return head;
}
 
int main(void)
{
    CreateList();
    return 0;
}
阅读(770) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~