- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * typedef struct date { int year; int month; int day; } DATE; DATE birthday; DATE *p; typedef int Status; Status initialization(void); typedef int NUM[100]; NUM a; typedef char *STRING; STRING p; 为已有类型引入一个同义词的方法: ①声明变量 ②将变量名换成新类型名 ③在最前面加上typedef ④使用新类型名声明变量 int a[100]; int NUM[100]; typedef int NUM[100]; NUM a; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #include stdio.h #include stdlib.h struct student { char sno[8]; char name[20]; char sex; int age; double score; }; int main(void) { struct student *p; p = (struct student *)malloc(sizeof(struct student)); scanf(%c%s%s%d%lf,p-sex, p-sno, p-name, p-age, p-score); 输出信息 free(p); p = NULL; return 0; } 二、单链表的基本操作 通常用结构体类型的变量来表示单链表中的结点,一个结构体类型的变量包含若干成员,用指针类型的成员存储下一个结点的地址 struct student { char sno[8]; char name[20]; char sex; int age; double score; struct student *next; }; 【例10.12】 建立一个学生信息的单链表,输出单链表中的学生信息,然后销毁单链表 #include stdio.h #include stdlib.h struct student { char sno[8]; char name[20]; char sex; int age; double score; struct student *next; }; void insert_node(struct student *head, struct student *p); void traverse(struct student *head); void delete_node(struct student *head); int main(void) { struct student *h, *q; int i, n; ... return 0; } printf(Input the number of students: ); scanf(%d, n); getchar( ); h = (struct student *)malloc(sizeof(struct student)); h-next = NULL; printf(Input %d students information(sex,sno,name,age,score):\n,n); for (i = 0; i n; i++) { q = (struct student *)malloc(sizeof(struct student)); scanf(%c%s%s%d%lf, q-sex, q-sno, q-name, q-a
您可能关注的文档
最近下载
- 福建省突发化学中毒卫生应急预案.doc VIP
- (最新)执业兽医师聘用协议合同书5篇.docx
- 盘扣式落地式卸料平台专项施工方案新版.docx VIP
- 2025年中国私募股权基金行业市场运行现状及投资战略研究报告.docx
- 护理礼仪与人际沟通.pptx VIP
- 二次函数复习课公开课二次函数复习课公开课.ppt VIP
- 电力工程项目建设用地指标(风电场)(建标〔2011〕209号).pdf VIP
- DB3301_T0329.1—2020_社会救助家庭家境调查规范第1部分:工作程序_杭州市 .docx VIP
- 建筑工程师工作总结范文.pptx
- 2025年中考语文二轮总复习:说明文阅读(附答案解析).doc
文档评论(0)