文档详情

C语言程序设计第三版谭浩强课后习题答案完整版(15页).doc

发布:2015-09-10约字共15页下载文档
文本预览下载声明
电信学院 机械二班 田文博 学号:0613100215 1.5 #include stdio.h void main() { printf(* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n); printf( Very good! \n); printf(* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n); } 1.6 #include stdio.h void main() { float max(float x,float y,float z); float a,b,c; printf(请分别输入a,b,c:\n); scanf(%f,%f,%f,a,b,c); printf(max=%f,max(a,b,c)); } float max(float x,float y,float z) { float m,n; m=xy? x: y; n=mz? m: z; return(n); } 3.6 #include stdio.h void main() { char c1=’a’,c2=’b’,c3=’c’,c4=’\101’,c5=’\116’; printf(“a%c b%c\tc%c\tabc\n”,c1,c2,c3); printf(“\t\b%c %c\n”,c4,c5); } 3.9.1 #include stdio.h void main() { double x=2.5,y=4.7,z; int a=7; z=x+a%3*(int)(x+y)%2/4; printf(该表达式的值为:%f,z); } 3.9.2 #include stdio.h void main() { int a=2,b=3; float x=3.5,y=2.5,z; z=(float)(a+b)/2+(int)x%(int)y; printf(该表达式的值为:%f,z); } 4.5 #include stdio.h void main() { int a=5,b=7; double x=67.8564,y=-789.124; char c=A; long n=1234567; unsigned u=65535; printf(%d%d\n,a,b); printf(%3d%3d\n,a,b); printf(%f,%f\n,x,y); printf(%-10f,%-10f\n,x,y); printf(%8.2f,%8.2f,%.4f,%.4f,%3f,%3f\n,x,y,x,y,x,y); printf(%e,%10.2e\n,x,y); printf(%c,%d,%o,%x\n,n,n,n); printf(%ld,%lo,%x\n,n,n,n); printf(%u,%o,%x,%d\n,u,u,u,u); printf(%s,%5.3s\n,COMPUTER,COMPUTER); } 4.6 #include stdio.h void main() { int a,b; float x,y; char c1,c2; scanf(a=%d b=%d,a,b); scanf( %f %e,x,y); scanf( %c %c,c1,c2); } 4.7 #includestdio.h void main() { int a,b; float x,y,z; char c1,c2; scanf(%5d%5d,a,b); scanf(%f%f%*f%f,x,y,z); scanf(%c%c,c1,c2); } 4.8 #include stdio.h #define pi 3.14 void main() { float r,h,l,s1,s2,v1,v2; printf(请输入r,h的值:\n); sca
显示全部
相似文档