ImageVerifierCode 换一换
格式:DOCX , 页数:17 ,大小:16.37KB ,
资源ID:14680095      下载积分:1 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-14680095.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(第九章课后习题答案.docx)为本站会员(b****1)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

第九章课后习题答案.docx

1、第九章课后习题答案9.1结构体可以把不同类型的数据组合成一个整体。与数组相比,数组中的元素是按照下标来进行访问的,而结构体是按照用户定义的结构体变量名来访问其成员的。9.2因为在定义结构体时系统并没有为其中的成员分配任何存储空间,而只有定义了结构体变量后,系统才为其中的各成员分配了相应的空间,所以先定义结构体变量,然后才能为结构体变量的成员进行赋值操作,否则,没有任何意义。9.3#include#define N 10typedef struct char numN; /学号 char nameN; /姓名 int age; /年龄 int score; /成绩,若有多门成绩,则可将该变量定义

2、成数组形式ST;void input_fun(ST *); /输入函数void output_fun(ST *); /输出函数void main() char choice=Y; ST stu; while(choice=Y|choice=y) /是否继续输入 input_fun(&stu); getchar(); output_fun(&stu); printf(Continue?); choice=getchar(); void input_fun(ST *p) printf(The num:); scanf(%s,p-num); printf(The name:); scanf(%s,p

3、-name); printf(The age:); scanf(%d,&p-age); printf(The score:); scanf(%d,&p-score);void output_fun(ST *q) printf(The num:); puts(*q).num); printf(The name:); puts(*q).name); printf(The age:%dn,(*q).age); printf(The score:%dn,(*q).score);9.4#include#define N 10struct sdata int year; int month; int da

4、y;typedef struct char numN; /学号 char nameN; /姓名 struct sdata birthday; /生日 int score; /成绩,若有多门成绩,则可将该变量定义成数组形式ST;void input_fun(ST *); /输入函数void output_fun(ST *); /输出函数void main() char choice=Y; ST stu; while(choice=Y|choice=y) /是否继续输入 input_fun(&stu); getchar(); output_fun(&stu); printf(Continue?);

5、 choice=getchar(); void input_fun(ST *p) printf(The num:); scanf(%s,p-num); printf(The name:); scanf(%s,p-name); printf(The birthday:n); printf( the year:); scanf(%d,&p-birthday.year); printf( the month:); scanf(%d,&p-birthday.month); printf( the day:); scanf(%d,&p-birthday.day); printf(The score:);

6、 scanf(%d,&p-score);void output_fun(ST *q) printf(The num:); puts(*q).num); printf(The name:); puts(*q).name); printf(The data:%d.%d.%dn,(*q).data.year,(*q).data.month,(*q).data.day); printf(The score:%dn,(*q).score);9.5#include#define N 5#define M 10typedef struct char numM; char nameM; int price;

7、int amount;GOODS;void initialize(GOODS *);void priarr(GOODS *);void priprice(GOODS *);void main() GOODS goodsN; initialize(goods); priarr(goods); priprice(goods);void initialize(GOODS goods) int i; for(i=0;iN;i+) printf(please input the goods num:); scanf(%s,goodsi.num); printf(please input the good

8、s name:); scanf(%s,goodsi.name); printf(please input the goods price:); scanf(%d,&goodsi.price); printf(please input the goods amount:); scanf(%d,&goodsi.amount); void priarr(GOODS goods) int i; printf(The list is:n); printf( num name price amountn); for(i=0;iN;i+) printf(%4s%8s%8d%8dn,goodsi.num,go

9、odsi.name,goodsi.price,goodsi.amount);void priprice(GOODS goods) int sum=0; int sumi=1; int i,j; for(i=0;iN;i+) sumi=1; sumi=goodsi.amount*goodsi.price; sum=sum+sumi; printf(The all gross is:%dn,sum);9.6#include#define N 10#define M 3typedef struct char numN; /学号 char nameN; /姓名 int age; /年龄 int sco

10、re; /成绩,若有多门成绩,则可将该变量定义成数组形式ST;void input_fun(ST *); /输入函数void output_fun(ST *); /输出函数void order(ST *);int average(ST *);void main() char choice=Y; ST stuM; int i; int ave; for(i=0;inum); printf(The name:); scanf(%s,p-name); printf(The age:); scanf(%d,&p-age); printf(The score:); scanf(%d,&p-score);

11、void output_fun(ST *q) printf(n num name age scoren); for(int i=0;iM;i+) printf(%7s%8s%8d%8dn,qi.num,qi.name,qi.age,qi.score);void order(ST t) ST temp; int i; for(i=0;iM-1;i+) for(int j=i+1;jM;j+) if(ti.scoretj.score) temp=ti; ti=tj; tj=temp; int average(ST t) int i; int sum=0; int ave; for(i=0;iM;i

12、+) sum+=ti.score; ave=sum/M; return ave;9.7#include#include#define N 10struct student char numN; int score; struct student *next;void readlist(struct student *);void main() struct student *head,*q,*m; char choice=Y; if(m=(struct student *)malloc(sizeof(struct student) m-next=NULL; head=m; while(choi

13、ce=Y|choice=y) if(q=(struct student *)malloc(sizeof(struct student) printf(Input the num:); scanf(%s,q-num); printf(Input the score:); scanf(%d,&q-score); q-next=NULL; getchar(); m-next=q; m=m-next; printf(Continue?); choice=getchar(); readlist(head); void readlist(struct student *stu) struct studen

14、t *p; p=stu-next; do printf(the num:); printf(%sn,p-num); printf(the score:); printf(%dn,p-score); p=p-next; while(p!=NULL);9.8#include#include#define N 10struct student char numN; int score; struct student *next;void readlist(struct student *);void main() struct student *head,*q,*m,*k,*n; char choi

15、ce=Y; if(m=(struct student *)malloc(sizeof(struct student) m-next=NULL; head=m; while(choice=Y|choice=y) if(q=(struct student *)malloc(sizeof(struct student) printf(Input the num:); scanf(%s,q-num); printf(Input the score:); scanf(%d,&q-score); q-next=NULL; getchar(); if(head-next=NULL) m-next=q; m=

16、m-next; else if(m-score=q-score) m-next=q; m=m-next; else n=head; k=n-next; while(k-next!=NULL&k-scoreq-score) n=k; k=k-next; q-next=k; n-next=q; printf(Continue?); choice=getchar(); readlist(head); void readlist(struct student *stu) struct student *p; p=stu-next; printf(num scoren); do printf(%5s%5

17、dn,p-num,p-score); p=p-next; while(p!=NULL);9.9#include#includetypedef struct int year; int month; int day;DATA;typedef struct document char num10; DATA data; struct document *next;DOC;void inqueue(DOC *,DOC *,DOC *);void outqueue(DOC *,DOC *);void main() char choice=Y; char add=Y; char del; DOC *fr

18、ont,*rear,*p; front=(DOC *)malloc(sizeof(DOC); front-next=NULL; rear=front; p=rear; while(add=Y|add=y) inqueue(front,rear,p); getchar(); printf(Continue add document?); add=getchar(); p=(DOC *)malloc(sizeof(DOC); getchar(); printf(deal with document?); del=getchar(); while(del=Y|del=y) outqueue(fron

19、t,rear); front=front-next; getchar(); printf(Continue deal with document?); del=getchar(); if(del=N|del=n) break; void inqueue(DOC *front,DOC *rear,DOC *q) printf(enter the num:); scanf(%s,q-num); printf(enter the year:); scanf(%d,&q-data.year); printf(enter the month:); scanf(%d,&q-data.month); pri

20、ntf(enter the day:); scanf(%d,&q-data.day); rear-next=q; rear=q; rear-next=NULL; void outqueue(DOC *front,DOC *rear) DOC *p; if(front=NULL&rear=NULL) printf(Its a empty queue!n); else p=front; printf(The deal with document:n); printf(the num:%5s the date:%4d.%d.%dn,p-num,p-data.year,p-data.month,p-data.day);

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2