600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > c语言程序设计江宝钏第九章 C语言程序设计 (江宝钏 著) 清华大学出版社 第9章习题答案1...

c语言程序设计江宝钏第九章 C语言程序设计 (江宝钏 著) 清华大学出版社 第9章习题答案1...

时间:2020-08-26 11:14:25

相关推荐

c语言程序设计江宝钏第九章 C语言程序设计 (江宝钏 著) 清华大学出版社 第9章习题答案1...

C语言程序设计 (江宝钏 著) 清华大学出版社 第9章习题答案1

一、程序阅读题 习题 9 答案 1.B2. C 二、编程题 1. #include #defineM 10 structstudent { intstu_id; 3. D 4. C }; charstu_name[8]; structdate { intyear; intmonth; }birthday; floatstu_course[3]; floatstu_avg; voidmain() { inti; structstudent p[M]; for(i=0;isalary=1.05*(pwork->salary); pwork->income=pwork->salary+pwork->bonus-pwork->deduction; } for(i=0;iname,pwork->salary,pwork->bonus,pwork->deduction, pwork->income); } } 3. #include intmain() {charop; doublea1,a2,b1,b2; intnumber; number=2;//run the program for third time do {printf(“please a1,a2,b1,b2 and opteration \n“); scanf(“%lf,%lf,%c,%lf,%lf“, switch(op) {case + : printf(“(%lf+%lfi)+(%lf+%lfi)=%lf+%lfi“,a1,a2,b1,b2,a1+b1,a2+b2); case - : printf(“\n“); break; printf(“(%lf+%lfi)-(%lf+%lfi)=%lf+%lfi“,a1,a2,b1,b2,a1-b1,a2-b2); printf(“\n“); break; case * : printf(“(%lf+%lfi)*(%lf+%lfi)=%lf+%lfi“,a1,a2,b1,b2,a1*b1-a2*b2,a1*b2+a2*b1); printf(“\n“); break; default: printf(“error\n“); } }while(number--); return0; } 4. #include“stdio.h“ structCandidate//define the Candidate struct {intId; charName[6] ; intBallot_Num; }; //define the global variableand initaliz the four candidates structCandidate Total[4]={ {1,“wang“,0}, {2,“liu“,0}, {3,“li“,0}, {4,“zhou“,0} }; //function for display the Candidates names voidPrintName(chara[]){ char*p; p=a; while((*p >= a p++; } } //function for display the Candidates inforamtion voidprint_Candi_inf(Candidate Total[]) { printf(“Can_ID,Can_name,Ballot_Num\n“); intj; for(j=0;j<4;j++) { printf(“***********************\n“); printf(“%d“,Total[j].Id); printf(“ “); PrintName(Total[j].Name); printf(“ “); } printf(“%d“,Total[j].Ballot_Num); printf(“\n“); } // function for count the candidate s ballot voidVote(intt) {inti; for(i=0;i0); return0; }

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。