九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

歡迎來到裝配圖網(wǎng)! | 幫助中心 裝配圖網(wǎng)zhuangpeitu.com!
裝配圖網(wǎng)
ImageVerifierCode 換一換
首頁 裝配圖網(wǎng) > 資源分類 > DOC文檔下載  

c語言程序設(shè)計(jì)(科學(xué)出版社)課后習(xí)題解答.doc

  • 資源ID:1546546       資源大?。?span id="24d9guoke414" class="font-tahoma">57.50KB        全文頁數(shù):16頁
  • 資源格式: DOC        下載積分:32積分
快捷下載 游客一鍵下載
會(huì)員登錄下載
微信登錄下載
三方登錄下載: 微信開放平臺(tái)登錄 支付寶登錄   QQ登錄   微博登錄  
二維碼
微信掃一掃登錄
下載資源需要32積分
郵箱/手機(jī):
溫馨提示:
用戶名和密碼都是您填寫的郵箱或者手機(jī)號(hào),方便查詢和重復(fù)下載(系統(tǒng)自動(dòng)生成)
支付方式: 支付寶    微信支付   
驗(yàn)證碼:   換一換

 
賬號(hào):
密碼:
驗(yàn)證碼:   換一換
  忘記密碼?
    
友情提示
2、PDF文件下載后,可能會(huì)被瀏覽器默認(rèn)打開,此種情況可以點(diǎn)擊瀏覽器菜單,保存網(wǎng)頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請(qǐng)使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站資源下載后的文檔和圖紙-無水印,預(yù)覽文檔經(jīng)過壓縮,下載后原文更清晰。
5、試題試卷類文檔,如果標(biāo)題沒有明確說明有答案則都視為沒有答案,請(qǐng)知曉。

c語言程序設(shè)計(jì)(科學(xué)出版社)課后習(xí)題解答.doc

_第3章 習(xí)題解答 第1章 1.C 語言程序主要由預(yù)處理命令、函數(shù)、注釋等組成。 2.填空 (1)分號(hào) (2)main (3)stdio.h 3. 源程序: #include<stdio.h> main( ) printf(“*n”); printf(“Hello World!n”); printf(“*”); 4. 源程序: #include <stdio.h> main( ) int a, b, c; /* 定義變量 */ scanf(“%d”, &a); /* 輸入第一個(gè)整數(shù) */ scanf(“%d”, &b); /* 輸入第二個(gè)整數(shù) */ c=a-b; /* 計(jì)算差 */ printf(“%d-%d=%d”,a,b,c); /* 輸出結(jié)果 */ 5. (1)<stdio.h> (2)x=10; (3)printf(“s=%dn”,s); 第2章 1. (1) c (2) a (3) b g (4) a d e (5) d 2. a. 5 b. 295 c. 4 d. 29 e. 9 3. a.x=4,y=6 b. x=4,y=3 f.x=3,y=6 4. 16 5. #include<stdio.h> main() int a,b,c; scanf("%d%d",&a,&b); c=a*b; printf("%d*%d=%d",a,b,c); 第3章 1. (1) b (2) b (3) d (4) a (5) b 2. (1)&a,&b (2)l,s 3. printf(“x=%.2f,y=%.2fn”,x,y); 4. #include<stdio.h> main() int num1,num2,num3,sum; float average; scanf("%d%d%d",&num1,&num2,&num3); sum=num1+num2+num3; average=sum/3.0; printf("sum=%d,average=%.2fn",sum,average); 5. #include<stdio.h> main() int hour,minute,second,total; /* 定義變量代表時(shí)、分、秒和總秒數(shù) */ scanf("%d",&total); hour=total/3600; minute=total%3600/60; second=total%3600%60; printf("%dhours:%dminutes:%dsecondsn",hour,minute,second); 第4章 1. (1) a (2) b (3) b (4) b (5) b 2. 0 3. (1) 6 (2) 4 (3) 1 (4) 1 4. #include <stdio.h> main( ) int x,y; scanf("%d",&x); if (x>-5 && x<0) y=5*x; if (x = 0) y=-1; if (x>0 && x<10) y=2*x+1; printf("x=%d,y=%dn",x,y); 5. #include <stdio.h> main( ) int score,rank; /* score 表示成績(jī),rank 表示級(jí)別 */ printf("Please input score:"); scanf("%d",&score); rank=score/10; switch(rank) case 10: case 9: printf("成績(jī)等級(jí)為:An"); break; case 8: printf("成績(jī)等級(jí)為:Bn"); break; case 7: printf("成績(jī)等級(jí)為:Cn"); break; case 6: printf("成績(jī)等級(jí)為:Dn"); break; default:printf("成績(jī)等級(jí)為:En"); break; 6. #include<stdio.h> void main() int n; printf("Please input the digit:"); scanf("%d",&n); switch(n) case 1:printf("Jan n");break; case 2:printf("Feb n");break; case 3:printf("Mar n");break; case 4:printf("Apr n");break; case 5:printf("May n");break; case 6:printf("Jun n");break; case 7:printf("Jul n");break; case 8:printf("Agu n");break; case 9:printf("Sep n");break; case 10:printf("Oct n");break; case 11:printf("Nov n");break; case 12:printf("Dec n");break; 第5章 1. (1) b (2) a (3) b (4) d (5) d 2. 7,1 3. y=-1 4. m=6 5. 10,14 6. 3 7. 5 8. ABABCDCD 9. # include <stdio.h> main ( ) int i; long int sum=0; for (i=2;i<=200;i+=2) sum+=i; printf("2+4+6+.+200=%ld",sum); 10. #include <stdio.h> main() long int n; int sum = 0; printf("Please input the nber:"); scanf("%ld",&n); while(n != 0) sum += n % 10; n /= 10; printf("%dn", sum); 第6章 1. (1) d (2) b (3) d (4) c (5) a 2. 11 3. 3 4. 5689 5. 12,6 6. (1) i- (2) n 7. (1) char k; (2) i<j 8. #include <stdio.h> main( ) float a10; int i; float sum=0,average; for (i=0;i<10;i+) printf("a%d=?",i); scanf("%f",&ai); sum+=ai; average=sum/10; printf("average is %.2fn",average); 9. #include <stdio.h> #define N 10 main( ) int aN,i,target,found; for (i=0;i<N;i+) scanf("%d",&ai); printf("Please input a number:"); scanf("%d",&target); i=0; while(i<N && target != ai) i+; found = i<N?i:-1; printf("%dn",found); 10. #include <stdio.h> #define N 80 main( ) char strN; int len=0,i=0; printf("Please input a string:"); gets(str); while (stri+ != 0) len+; printf("the length of string is %d.n",len); 第7章 1. 21 2. 136 3. 16 4. (1) func (2) m+ 5. 9 6. 1,6,3,2,3 7. 2,5,1,2,3,-2 8. #include <stdio.h> int fun(int a,int b,int c); main( ) int a,b,c,max; printf("Please input three numbers:"); scanf("%d%d%d",&a,&b,&c); max=fun(a,b,c); printf("Max is %d.n",max); int fun(int a,int b,int c) int max; max= a>b?(a>c?a:c):(b>c?b:c); return max; 9. #include <stdio.h> long int sum(int n); main( ) int n; printf("n=?"); scanf("%d",&n); printf("Sum=%ld.n",sum(n); long int sum(int n) if (n = = 1 ) return 1; else return sum(n-1)+n; 10. #include <stdio.h> void fun(n); main( ) int n; printf("n=?"); scanf("%d",&n); fun(n); void fun(n) if (n = = 0) return; else fun(n/2); printf("%-2d",n%2); 第8章 1. (1) b (2) d (3) b (4) c (5) c 2. 8 3. 123456789 4. 2 3 4 5 6 5. 345 6. 1 2 3 4 5 6 7. bi 8. bcdefgha 9. p=sum 10. #include <stdio.h> #include <string.h> main() char str80; char *p1, *p2; gets(str); p1=str; p2=str+strlen(str)-1; while (p1<p2 && *p1+ = *p2- ) ; puts( p1<p2 ? "不是回文" : "是回文" ); 第9章 1. a. #define F(x) (x)*(x)*(x) b. #define F(x) (x)%4 c. #define F(x,y) (x)*(y)<100?1:0 2. a. 4 b. 4 c. #define DOUBLE(x) 2*(x) 3. d 4. -20 5. N is undefined 6. 7.5 7. y=6 8. #include <stdio.h> #define SWAP(a,b) int temp;temp=a;a=b;b=temp; main() int x,y; printf("x=?"); scanf("%d",&x); printf("y=?"); scanf("%d",&y); SWAP(x,y) printf("x=%d,y=%d.n",x,y); 第10章 1. struct student int sno; char sname10; char sex; stu1,stu2; 2. 12 3. 合法的有a,b,d c.改成 s.u.rectangle.length=25; e.改成 s.u.circle.radius=5; f.改成 s.u.circle.radius=5; 4. a,b,c,d (說明:變量 b 有確定的值之后,b+是合法的。) 5. 改為 typedef struct product char name10; float price; PRODUCT; PRODUCT products10; 6. (1) struct employee (2) printemp(emp) 7. 2 4 3 9 8 8. #include <stdio.h> struct time_struct int hour; int minute; int second; ; main( ) struct time_struct time; printf("Input time?n(Example 18:28:38)n"); scanf("%d:%d:%d",&time.hour,&time.minute,&time.second); printf("Time is %d:%d:%dn",time.hour,time.minute,time.second); 9. #include <stdio.h> struct time_struct int hour; int minute; int second; time; void enter_time(); void display_time(); main( ) enter_time(); display_time(); void enter_time() printf("Enter the time(example 18:28:38)?"); scanf("%d:%d:%d",&time.hour,&time.minute,&time.second); void display_time() printf("Time is %d:%d:%d.n",time.hour,time.minute,time.second); 10. #include <stdio.h> #define N 3 struct hotel char name31; /*旅館名稱*/ char address31;/*旅館地址*/ int grade; /*旅館級(jí)別*/ float average_charge; /*平均房?jī)r(jià)*/ int number; /*房間數(shù)量*/ hN= "h1","上海路",5,500.00,80, "h2","北京大街",5,480.00,70, "h3","南京大街",3,300.50,100 ; main( ) int grade,i; printf("請(qǐng)輸入級(jí)別(3-5)?"); scanf("%d",&grade); for (i=0;i<N;i+) if (hi.grade=grade) printf("名稱:%sn 地址:%sn 級(jí)別:%dn平均房?jī)r(jià)%.2fn 房間數(shù)量:%dn", hi.name,hi.address,hi.grade,hi.average_charge,hi.number); 第11章 1. (1) c (2) d (3) b (4) b (5) b 2. Basican 3. fgetc(fp) 4. “record.dat”, “w” 5. #include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct Employee int id; char name20; char gender20; int age; char address20; Employee; int main(void) FILE *fp; char another,choice; Employee emp; long int recsize; fp=fopen("employee.dat","rb+"); if(fp=NULL) fp=fopen( "employee.dat","wb+"); if(fp=NULL) printf("Can't Open File"); exit(0); recsize=sizeof(emp); while(1) printf("1.添加記錄 2.顯示男員工 3.退出n"); printf("Enter your choice(1-3):"); fflush(stdin); scanf("%c",&choice); switch(choice) case'1': fseek(fp,0,SEEK_END); another='Y' while(another='Y'| another='y') printf("輸入信息(id 姓名 性別 年齡 住址):n"); scanf("%d %s %s %d %s",&emp.id,&emp.name,&emp.gender,&emp.age,&emp.address); fwrite(&emp,recsize,1,fp); printf("是否繼續(xù) (Y/N): "); fflush(stdin); another=getchar(); break; case '2': printf("學(xué)號(hào)t 姓名t性別t 年齡t住址n"); rewind(fp); while(fread(&emp,recsize,1,fp)=1) if (strcmp(emp.gender,"男")=0) printf("%dt%st%st%dt%sn", emp.id,emp.name,emp.gender,emp.age,emp.address); break; case '3': fclose(fp); exit(0); 6. #include"stdio.h" #include"stdlib.h" #define M 2 #define stu struct student stu int num; char name20; float s1; float s2; float s3; float avg; ; main() stu stM; FILE *fp; int i; printf("請(qǐng)輸入 5 名同學(xué)生的成績(jī),按照學(xué)號(hào),姓名,成績(jī) 1,成績(jī)2,成績(jī) 3 的順序,中間用空格隔開:n"); for(i=0;i<M;i+) scanf("%d%s%f%f%f",&sti.num,sti.name,&sti.s1,&sti.s2,&sti.s3); sti.avg=(sti.s1+sti.s2+sti.s3)/3; if(fp=fopen("stud.rec","wb")=NULL) printf("cannot open filen"); for(i=0;i<M;i+) if(fwrite(&sti,sizeof(stu),1,fp)!=1) printf("file write errorn"); fclose(fp); fp=fopen("stud.rec","rb"); printf("numtnametscore1tscore2tscore3taveragen"); for(i=0;i<M;i+) fread(&sti,sizeof(stu),1,fp); printf("%dt%st%.2ft%.2ft%.2ft%.2fn",sti.num,sti.name,sti.s1,sti.s2,sti.s3,sti.avg); fclose(fp); 第12章 1. a. 2 b. 4 c. 11 d. 4 e. -15 f. 28 g. -36 2. 程序設(shè)計(jì)分析:先將整數(shù)x 右移4 位,將該整數(shù)機(jī)內(nèi)碼的第4 到7 位移至第0 到3 位, 然后與0x000f(0000000000001111)進(jìn)行位與運(yùn)算,所保留的低4 位就是所要的結(jié)果 #include <stdio.h> void main() int x,y; scanf("%d",&x); y=x>>4; y=y&0x000f; printf("47位的十六進(jìn)制數(shù):y=%#xn",y); 3. d 4. (1) p!=NULL (2)p=p->next 5. p=p->next 6. 略 THANKS !致力為企業(yè)和個(gè)人提供合同協(xié)議,策劃案計(jì)劃書,學(xué)習(xí)課件等等打造全網(wǎng)一站式需求歡迎您的下載,資料僅供參考-可編輯修改-

注意事項(xiàng)

本文(c語言程序設(shè)計(jì)(科學(xué)出版社)課后習(xí)題解答.doc)為本站會(huì)員(最***)主動(dòng)上傳,裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。 若此文所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng)(點(diǎn)擊聯(lián)系客服),我們立即給予刪除!

溫馨提示:如果因?yàn)榫W(wǎng)速或其他原因下載失敗請(qǐng)重新下載,重復(fù)下載不扣分。




關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!