| 查看: 455 | 回复: 2 | ||
[求助]
C语言链表的建立,有几个地方看不懂,请大神指导 已有1人参与
|
|
#include <stdio.h> #include <stdlib.h> #include <malloc.h> #define NULL 0 struct stu{ long num; float score; struct stu *next; }; typedef struct stu Stu_link; Stu_link *cre_link(){ Stu_link *head=NULL,*last=NULL,*p; p=(Stu_link *)malloc(sizeof(Stu_link));//开辟节点 printf("input num:" ;scanf("%d",&(p->num)); printf("input score:" ;scanf("%d",&(p->score)); p->next=NULL; while(p->num){ if(head=NULL){ head=p; last=p; } else{ last->next=p; head=p; } p=(Stu_link *)malloc(sizeof(Stu_link));//开辟新节点 printf("input num:" ;scanf("%d",&(p->num)); if(p->num){ printf("input score:" ;scanf("%d",&(p->score)); p->next=NULL; } } return head; } int main() { cre_link(); system("pause" ;return 0; } 其中的如下语句: if(head=NULL){ head=p; last=p; } else{ last->next=p; head=p; } 请问这几句怎么理解? |
» 猜你喜欢
拟解决的关键科学问题还要不要写
已经有8人回复
最失望的一年
已经有14人回复
求助一下有机合成大神
已经有3人回复
存款400万可以在学校里躺平吗
已经有30人回复
求推荐英文EI期刊
已经有5人回复
请教限项目规定
已经有4人回复
26申博
已经有3人回复
基金委咋了?2026年的指南还没有出来?
已经有10人回复
基金申报
已经有6人回复
疑惑?
已经有5人回复

duotojh
金虫 (小有名气)
- 应助: 9 (幼儿园)
- 金币: 1066.6
- 红花: 5
- 帖子: 225
- 在线: 137.8小时
- 虫号: 1290636
- 注册: 2011-05-09
- 专业: 生物物理、生物化学与分子
2楼2014-11-13 21:25:54
duotojh
金虫 (小有名气)
- 应助: 9 (幼儿园)
- 金币: 1066.6
- 红花: 5
- 帖子: 225
- 在线: 137.8小时
- 虫号: 1290636
- 注册: 2011-05-09
- 专业: 生物物理、生物化学与分子
3楼2014-11-13 21:53:09













;
回复此楼