全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第9章习题一、选择题12345678910DDACBDCDDB1112131415CDBCA二 填空题1. 成员 指向2. stu 或 struct student311 20 114. printf(“%s”,p-name);5. pp15 struct pp *f();6. (*p).sex or p-sex7. 28. Mary9. r-next=q; p-next=r;10. 32三 程序分析题1. 212. 1999.4 zhang 1999.4 zhang y hang3. 5,34. 1,215. 13四、编程题1. 设计一个通讯录的结构体类型,并画出该结构体变量在内存的存储形式。typedef struct int no; char name15; char gender; char mobile20; char phone20; char address30; Contacts;Contacts con;2. 用结构体变量表示平面上的一个点(横坐标和纵坐标),输入两个点,求两点之间的距离。#include stdio.h#include math.htypedef struct float x; float y; Point;float distance(Point a, Point b) float dis; dis=sqrt(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); return dis;void main() Point a, b; printf(Please input the value of point a(Format: x,y):); scanf(%f,%f, &a.x, &a.y); printf(Please input the value of point b(Format: x,y):); scanf(%f,%f, &b.x, &b.y); printf(The distance between the two points is : %.3f n, distance(a,b);3. 用结构体变量表示日期(年、月、日),任意输入两个日期,求它们之间相差的天数。#include stdio.htypedef struct int year; int month; int day; Date;void main() int month12= 0,31,59,90,120,151,181,212,243,273,304,334, year; Date s, e; long sn, en; printf(Fromat: 2006-6-16-1989-01-25n); scanf(%ld-%ld-%ld-%ld-%ld-%ld, &s.year, &s.month, &s.day, &e.year, &e.month, &e.day); /* 计算起始日期距离公元元年的天数sn */ if( (s.year%4=0 & s.year%100!=0 | s.year%400=0 ) & s.month3 ) year=s.year/4 - s.year/100 + s.year/400 + s.year*365 - 1; else year=s.year/4 - s.year/100 + s.year/400 + s.year*365; sn = months.month - 1 + year + s.day; /* 计算终止日期距离公元元年的天数en */ if( (e.year%4=0 & e.year%100!=0 | e.year%400=0 ) & e.month3 ) year=e.year/4 - e.year/100 + e.year/400 + e.year*365 - 1; else year=e.year/4 - e.year/100 + e.year/400 + e.year*365; en = monthe.month - 1 + year + e.day; printf( There are %ld days between %ld-%ld-%ld and %ld-%ld-%ld.n , sn-en, s.year, s.month, s.day, e.year, e.month, e.day); 4. 用结构体变量表示复数(实部和虚部),输入两个复数,求两复数之积。#includetypedef struct int real; int image; Complex;void main() Complex c1, c2; int real, image; printf(Please input a complex (format: real image)n); scanf(%d%d, &c1.real, &c1.image); printf(Please input another complex (format: real image)n); scanf(%d%d, &c2.real, &c2.image); real=c1.real*c2.real-c1.image*c2.image; image=c1.real*c2.image+c2.real*c1.image; if(image0) printf(multipul result=%d+%din, real, image); else if(image0) printf(multipul result=%d%din, real, image); else printf(multipul result=%dn, real);5有20个学生,每个学生的数据包括学号(num)、姓名(name)、性别(sex)、五门课程成绩(score5)。要求编写一个程序,输入学生数据,计算并输出每个学生的总分和平均分。#include stdio.h#define STU_NUM 3typedef structchar no10;char name15;char sex;float score5; Student;void main()Student stuSTU_NUM;int i, j;float ave=0;/ inputfor(i=0; iSTU_NUM; i+)fflush(stdin);printf(Please input the no of %d student:, i+1);gets(stui.no);printf(Please input the name of %d student:, i+1);gets();printf(Please input the sex of %d student:, i+1);stui.sex=getchar();printf(Please input the five scores of %d student:, i+1);for(j=0; j5; j+)scanf(%f, &stui.scorej);printf(n);/ process and outputfor(i
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026中国食品品牌策划行业市场现状供需分析及投资评估规划分析研究报告
- 2026氢能源储运设备产业市场供需均衡发展咨询
- 2026中国文物保护行业发展与政策支持深度研究及市场趋势分析报告
- 2026南非黄金矿业行业市场运行分析及发展趋势与投资战略研究报告
- 2026中国智能交通违法拍摄系统行业市场现状供需分析及投资评估规划分析研究报告
- 2026中国叶黄素酯市场需求变化与消费者行为分析
- 2026乳制品行业质量追溯体系与行业监管改进与市场优化报告
- 2026食品添加剂行业市场竞争格局深度研究及产业发展与商业机会评估
- 2026前沿超高清显示设备行业市场供求形势分析及投资价值评估规划报告
- 2026中国智能家居传感器行业市场发展动态与竞争格局预测报告
- 2025年法院司法辅助人员真题附参考答案详解
- 第三章 3D服装设计基础应用(课件)-《服装设计与虚拟仿真表现》同步教学(纺织出版社)
- 2026宁夏中卫市海原县属国有企业领导人员招聘9人考试参考题库及答案详解
- 2026年烟台南山学院综合评价招生素质测试(笔试)模拟试题及答案(二)
- 《皮肤科诊疗指南及操作规范(2025版)》
- 2026年四川省达州市高一入学语文分班考试真题含答案
- 2025年浙江省杭州市公共基础辅警考试笔试题库及答案
- 销售转正述职报告
- QC/T 798-2025汽车用多层塑料燃油管
- 贸易安全培训课件
- T/CMEAS 010-2023标准化病人(SP)医学教育项目建设与应用指南
评论
0/150
提交评论