next)Рprintf("%d\t%s\n", p->num, p->name);Рprintf("\n");Р}Рstruct student *create()Р{Рstruct student *p = (st" /> next)Рprintf("%d\t%s\n", p->num, p->name);Рprintf("\n");Р}Рstruct student *create()Р{Рstruct student *p = (st" />

全文预览

结构体练习题

上传者:幸福人生 |  格式:docx  |  页数:14 |  大小:30KB

文档介绍
struct student *head)Р{Рstruct student *p;Рprintf("当前链表内容为:\n");Рfor(p=head; p!=NULL; p=p->next)Рprintf("%d\t%s\n", p->num, p->name);Рprintf("\n");Р}Рstruct student *create()Р{Рstruct student *p = (struct student *) malloc(sizeof(struct student));Рprintf("请输入学号与姓名(空格分隔,学号为0时停止输入):\n");Рscanf("%d%s", &p->num, p->name);Рp->next = NULL;Рif(p->num == 0)Рp = NULL;Рreturn p;Р}Рstruct student *add()Р{Рstruct student *head, *p0, *p1, *p2;Рp1 = create();Рhead = p1;Рlist(head);Рp0 = create();Рwhile(p0 != NULL)Р{Рp1 = head;Рwhile((p0->num > p1->num) && (p1->next!=NULL))Р{Рp2 = p1;Рp1 = p1->next;Р}Рif(p0->num < p1->num)Р{Рif(p1 == head)Рhead = p0;РelseРp2->next = p0;Рp0->next = p1;Р}РelseР{Рp1->next = p0;Рp0->next = NULL;Р}Рlist(head);Рp0=create();Р}Рreturn head;Р}Рint f(struct student *head)Р{Рint n;

收藏

分享

举报
下载此文档