| 查看: 516 | 回复: 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; } 请问这几句怎么理解? |
» 猜你喜欢
求各位大神看下
已经有29人回复
咨询面上基金
已经有7人回复
影响面上的因素
已经有11人回复
filecode
已经有4人回复
8月时间戳变的,举个手。玩一下,释放压力
已经有11人回复
一个有机合成实验室都需要哪些设备?
已经有11人回复
面上再次挂了,太难了,躺也躺不了,倦也卷不过,小学校之殇!
已经有30人回复
好消息?这个有何含义???
已经有10人回复
【2027博士申请】纳米药物递送方向
已经有4人回复
UV压敏胶开发
已经有7人回复

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










;
回复此楼