正在加载图片...
第二部分¢语言程序设计同步训练 263· struct link p= head->next printf("s=器d\n”,s) 3.以下动态建立一个学生数据的链表,写出创建链表的函数 create,以学号为0表示 输入结束,在 处填写正确内容 #include NULL 0 int float score struct student struct student *create(void I struct student *head *pl,*p2; n=0 pl=p2=( struct student *)malloc( scanf(”詈df",&p1->num,p1-> score); while(pl->numI=0) n=n+1; pl=p2=( struct student malloc(sizeof (struct student)) scanf("暑d暑f”,p1->num,&p1-> score) 选择题 1.已知head指向单链表的第一个节点,以下函数del完成从单向链表中删除值为num 的第一个结点。请选择正确内容填空。 #include <stdio. h struct student t int info struct student *link struct student *del(struct student *head, int num第二部分 C 语言程序设计同步训练 ·263· ·263· struct link { int data; struct link next; }; main() { struct link *head , *p; int s =0; p= head->next; while(p! =NULL) { s+=________________; p = __________________; printf(“s=%d\n”,s ); } 3. 以下动态建立一个学生数据的链表,写出创建链表的函数 create,以学号为 0 表示 输入结束,在___________处填写正确内容。 #include NULL 0 #include <stdio.h> struct student { int num ; float score ; struct student * next ; }; int n ; struct student *create(void) { struct student *head , * p1,*p2 ; n=0 ; p1=p2=( struct student * ) malloc(_________________) ; scanf (“%d%f”,&p1->num ,&p1->score); head = NULL; while(p1->num!=0) { n=n+1; if (n==1) head = p1; else _____________________; p2=p1; p1=p2=( struct student * ) malloc(sizeof(struct student)) ; scanf ( “%d%f”,&p1->num ,&p1->score); } p2->next =NULL; } 二、选择题 1. 已知 head 指向单链表的第一个节点,以下函数 del 完成从单向链表中删除值为 num 的第一个结点。请选择正确内容填空。 #include <stdio.h> struct student { int info; struct student *link; }; struct student *del(struct student *head, int num)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有