| 查看: 477 | 回复: 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; } 请问这几句怎么理解? |
» 猜你喜欢
本人考085602 化学工程 专硕
已经有23人回复
求调剂院校信息
已经有4人回复
085600材料与化工306
已经有4人回复
286求调剂
已经有10人回复
328求调剂,英语六级551,有科研经历
已经有9人回复
一志愿北京化工大学070300 学硕336求调剂
已经有4人回复
286分人工智能专业请求调剂愿意跨考!
已经有8人回复
资源与环境 调剂申请(333分)
已经有5人回复
280求调剂
已经有12人回复
269专硕求调剂
已经有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













;
回复此楼
10