新微赢技术网
标题:
[求助]链表没有输出来~
[打印本页]
作者:
让爱留在心底
时间:
2009-11-3 02:13
标题:
[求助]链表没有输出来~
struct student
{
long number;
float score;
student * next;
};
student * head; //链首指针
student * creat() //创建链表
{
student *ps; //结点指针
student *pend; //链尾指针
ps=new student; //分配内存空间,建立一个节点,准被插入链表
cin>>ps->number>>ps->score;
head=NULL; //开始链表为空
pend=ps;
while(ps->number!=0)
{
if(head==NULL)
pend=ps;
else
pend->next=ps;
pend=ps;
ps=new student;
cin>>ps->number>>ps->score;
}
pend->next=NULL;
delete ps;
return head;
}
void showlist(student * head)
{
cout<<"now the items of list are:"<<endl;
while(head)
{
cout<<head->number<<","<<head->score<<endl;
head=head->next;
}
}
void main()
{
showlist (creat());
}
输入后,显示now the items of list are: 下面就不显示了,输出有什么错误??
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2