帮忙看看:是编译器问题还是程序问题

biduan 2003-11-30 07:04:57
刚copy钱能的c++上的一道例题,是关于连表的问题,可是奇怪出现了
每当我运行是,总是到一半时候弹出“发送错误报告的对话框”晕啊,哪未看看到底是什么问题?
源程序如下:
#include<iostream.h>
struct Student
{
long number;
float scorse;
Student *next;
};
Student *head;
Student *Creat()
{
Student *ps;//创建结点指针
Student *pEnd;//链尾指针,用于其后面插入结点
ps=new Student ;//新建一个结点,准备插入链表
cin>>ps->number>>ps->scorse;
head=NULL; //一开始链表为空
pEnd=ps;
while(ps->number!=0)
{if(head==NULL)
head=ps;
else
pEnd=ps;
ps=new Student;
cin>>ps->number>>ps->scorse;
}
pEnd->next=NULL;
delete ps;
return(head);
}
void ShowList(Student *head)
{
cout<<"now the items of list are\n";
while(head)
{
cout<<head->number<<","<<head->scorse<<endl;
head=head->next;
}
}
void main()
{
ShowList(Creat());
}
...全文
31 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
abitz 2003-11-30
  • 打赏
  • 举报
回复
建表错误:
#include<iostream>
//#include<fstream>
//#include<iterator>
using namespace std;
struct Student
{
long number;
float scorse;
Student *next;
};
Student *head;
Student *Creat()
{
Student *ps;//创建结点指针
Student *pEnd;//链尾指针,用于其后面插入结点
ps=new Student ;//新建一个结点,准备插入链表
cin>>ps->number>>ps->scorse;
head=NULL; //一开始链表为空
pEnd=ps;
while(ps->number!=0)
{
if(head==NULL)
pEnd = head = ps;
else
{
pEnd->next = ps; //这里
pEnd = pEnd->next;
}
ps=new Student;
cin>>ps->number>>ps->scorse;
}
pEnd->next=NULL;
delete ps;
return(head);
}
void ShowList(Student *head)
{
cout<<"now the items of list are\n";
while(head)
{
cout<<head->number<<","<<head->scorse<<endl;
head=head->next;
}
}
void main()
{
ShowList(Creat());
}
heguobaoceo 2003-11-30
  • 打赏
  • 举报
回复
好象是有一点问题咯
   好象可以啊
    结果是:
input :12 13 14 15 0 0

     now the items of list are
12 ,13
「已注销」 2003-11-30
  • 打赏
  • 举报
回复
付:
我的验证输入数据为:
12 13 14 15 0 0
结果就..

65,210

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧