C语言的程序问题!
来源:百度知道 编辑:UC知道 时间:2024/05/07 18:54:35
谢谢各位,考试要用!
简单
struct Student //定义了一个学生结构
{
long number;
float score;
Student * next;
};
Student * head1; // 链首指针
Student * head2;
Student * Create1() // 创建第一个链表
{
Student * ps; // 结点指针
Student * pEnd; // 链尾指针
ps=new Student; // 新建结点
printf("请输入一班所有学生的学号和成绩:\n");
printf("学号 成绩\n");
scanf("%ld%f",&ps->number,&ps->score);// 输入学生的学号和成绩
head1=NULL; // 开始链表为空
pEnd=ps;
while(ps->number!=0)
{
if(head1==NULL)
head1=ps; // 若链表为空,则使头指针指向第一个结点
else
pEnd-