资源描述:
《C语言程序设计课后习题答案 吉林大学版 武爱平.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、第一章1.选择题(1)B(2)C(3)C(4)D(5)B(6)D(7)D(8)C2.填空题(1)函数一个主函数函数(2)/**/(3)连接3.程序设计题(1) #includemain(){printf("*");printf("*S*");printf("*");}(2)#includemain(){printf("******************");printf("Yourarewelcome!");printf("------------------");}
2、第二章1.选择题(1)D(2)D(3)B(4)C(5)B(6)C(7)C(8)C(9)D(10)C(11)A(12)B(13)A(14)C(15)A(16)B(17)A(18)B(19)C(20)A(21)C(22)C2.填空题(1)①9②-2③62④44.8(2)①10.5②73.1③7④7.2(3)"%6x""%o""%3c""%10.3f""%8s"(4)inta,b,c;&a,&b,&ctemp=a;c=temp;(5)49613113.程序设计题(1)#includemain(){doublea,b,c
3、,d;doubleaver=0.0;printf("Pleaseinputfourdoublenumber:");scanf("%lf%lf%lf%lf",&a,&b,&c,&d);aver=(a+b+c+d)/4;printf("Theaverageofthefourdoublenumberis%lf",aver);}(2)#include#definePI3.14159main(){doubler;doublearea=0,len=0;printf("Pleaseinputr:");scanf("
4、%lf",&r);area=PI*r*r;len=2*PI*r;printf("area=%lf,length=%lf",area,len);}(3)#includemain(){floati,s;printf("Pleaseinputdata:");scanf("%f%f",&i,&s);s=s*(1+i);printf("Ihave%.2fyuanafteroneyear.",s);}第三章1、选择题(1)C(2)C(3)A(4)C(5)D(6)A(7)C(8)A(9)B(10)D2、填空题(1)
5、&m,&nm=n;n=temp;m,n(2)①554②554③334(3)9i+1"%d",iprintf("");(4)73-543932013、程序设计题(1)#include#includemain(){doublea,b,c,d,det,a_2,real,imag,x1,x2;printf("Pleaseentera,b,c:");scanf("%lf%lf%lf",&a,&b,&c);if(a==0&&b==0)printf("Noroot!");elseif(a==0)prin
6、tf("Lineequationrootis%.2lf",-c/b);else{d=b*b-4*a*c;det=sqrt(fabs(d));a_2=2*a;if(d<0){real=-b/a_2;imag=det/a_2;printf("Thetworootare:%.2lf+%.2lfi",real,imag);printf("and%.2lf-%.2lfi",real,imag);}elseif(d==0)printf("Singlerealrootis%.2lf:",-b/a_2);else{x1=-
7、b/(a_2)+det/a_2;x2=-b/(a_2)+det/a_2;printf("Thetworealrootsare:%.2lfand%.2lf",x1,x2);}}}(2)#includemain(){inti,j;for(i=1;i<=9;i++){for(j=1;j<=9;j++)printf("%d*%d=%2d",i,j,i*j);printf("");}}(3)#includemain(){floatsum,product;inti,n,j;printf(
8、"Entern(4<=n<=20):");scanf("%d",&n);while(n>20
9、
10、n<4){printf("Enternagain:");scanf("%d",&n);}sum=0;product=1;for(i=1;i<=