c语言程序设计教程第三版答案 第九章,C语言程序设计教程第九章习题答案.docx...

C语言程序设计教程第九章习题答案.docx

1、li 45 300.0chang 30 200.0chang2、#includestruct students{ char sid[100]; char name[100]; float score[3];}student;void main(){ int i; float j; printf("\nPlease input sid: "); scanf("%s",student.sid); printf("\nPlease input name: "); scanf("%s",student.name); printf("\nPlease input 3 score:(like1,1,1) ");/*输入逗号隔开*/ scanf("%f,%f,%f",&student.score[0],&student.score[1],&student.score[2]); printf("\nsid = %s",student.sid); printf("\nname = %s",student.name); j=(student.score[0]+student.score[1]+student.score[2])/3.0; printf("\naverage = %.2f",j); getch();}3、#include#include#define F sizeof(student)#define NULL 0typedef struct scores{int english;int math;int c_language;int all;}TP;typedef struct students{char sid[15];char name[15];TP score;struct students *next;}student;student *input(){student *head,*p1,*p2;int n=0; char ch;clrscr();head=(student *)malloc(F);head->next=NULL;do{ n++; printf("\n\nPlease input %d student message: \n\n",n); printf("\t%d student sid: ",n); p1=(student *)malloc(F);p1->next=NULL; scanf("%s",p1->sid); printf("\n\t%d student name: ",n); scanf("%s",p1->name); printf("\n\t%d student scores(englesh,math,c_language): ",n); scanf("%d,%d,%d",&p1->score.english,&p1->score.math,&p1->score.c_language); p1->score.all=p1->score.english+p1->score.math+p1->score.c_language; if(n==1) {head->next=p1;p2=p1; } else {p2->next=p1;p2=p1; } printf("\n\n\t\t\tContinue or back (press y/n): "); ch=getch(); }while(ch=='y'||ch=='Y');return head;}void average1(student *head){student *p; int j;clrscr();p=head->next; while(p) {j=p->score.all/3;printf("\n\nname: %s\taverage: %d",p->name,j);p=p->next; }printf("\n\n\nPress eny key return.");getch();}void average2(student *head)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值