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; }
超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術人生總結
以上是生活随笔為你收集整理的c语言程序设计江宝钏第九章,C语言程序设计 (江宝钏 著) 清华大学出版社 第9章习题答案1...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c语言第一个mfc程序,c语言之MFC的
- 下一篇: c或c++语言什么时候用补码来运算,C/