AI智能整理导入 AI智能整理导入
×
首页 题库中心 c语言程序设计题库 题目详情
CA85E835B92000012B50FB49F93816B5
c语言程序设计题库
1,073
单选题

下面的代码实现建立一个有若干名学生数据的单向动态链表,请填空。

#include
#include
#define LEN sizeof(struct student)
struct student
{ long num;
float score;
struct student * next;
};
int n;
struct student *creat();
void print(struct student * p);
main()
{
struct student *head;
________【1】__________;
display(head);
}
void print(struct student * p)
{
while(p)
{ printf("%ld\t%f\n",p->num, p->score);
_______【2】________; }
}


struct student *creat()
{
struct student *p1,*p2,*head;
long sno;
float score;
p1=p2=head=NULL;
______【3】_________;
while(1)
{ scanf("%ld,%f",&sno,&score);
if(sno==0) break;
n++;
p1=(struct student*)malloc(LEN);
p1->num=sno;
p1->score=score;
if(head==NULL)
head=p1;
else
_________【4】____________;
p2=p1;
}
if(p2) p2->next=NULL;
return head;
}

A
head=creat()
B
p=p->next
C
n=0
D
p2->next=p1

答案解析

正确答案:ABCD

解析:

结构体与共用体
c语言程序设计题库

扫码进入小程序
随时随地练习

关闭
专为自学备考人员打造
试题通
自助导入本地题库
试题通
多种刷题考试模式
试题通
本地离线答题搜题
试题通
扫码考试方便快捷
试题通
海量试题每日更新
试题通
欢迎登录试题通
可以使用以下方式扫码登陆
试题通
使用APP登录
试题通
使用微信登录
xiaochengxu
联系电话:
400-660-3606
xiaochengxu