资源描述:
《浙江农林大学c语言程序设计习题集答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第1~3章C语言概述、算法、数据类型、运算符与表达式一、选择题ACDCBCCDCBAD二、填空题1、n=202、a=66,b=E第4章顺序程序设计一、选择题BAAD二、程序阅读1、12240122、2,3,2,23、0三、编程1#include#includevoidmain(){floata,b,c,s,area;scanf("%f,%f,%f",&a,&b,&c);s=(a+b+c)/2.0;area=sqrt(s*(s-a)*(s-b)*(s-c));pr
2、intf("a=%f,b=%f,c=%f,area=%f",a,b,c,area);}2#include#includevoidmain(){floata,b,c,del,x1,x2;scanf("%f,%f,%f",&a,&b,&c);del=b*b-4*a*c;if(del>=0){x1=(-b+sqrt(del))/(2*a);x2=(-b-sqrt(del))/(2*a);printf("x1=%f,x2=%f",x1,x2);}elseprintf("
3、没有实根");}3#includevoidmain(){intc,f;c=26;f=9.0/5.0*c+32;printf("%d的华氏温度是%d",c,f);}第5章选择结构程序设计一、选择题DBBCDADBBCDC二、程序阅读1、
4、a
5、+
6、b
7、=612、PQ3、-14、60~9060error!5、0,16、x+y+z=15三、编程1#includevoidmain(){inta,b,c,min;scanf("%d,%d,%d",&a,&b,&c);min
8、=a;if(min>b)min=b;if(min>c)min=c;}2#includevoidmain(){inta;scanf("%d",&a);if(a%3==0&&a%5==0&&a%7==0)printf("yes");elseprintf("no");}3#include#includevoidmain(){floatx,y;scanf("%f",&x);if(x<0)y=fabs(x);elseif(x>=0&&x<=2)y=sqr
9、t(x+1);elseif(x>=2&&x<4)y=pow(x+2,3);elsey=2*x+5;printf("x=%f,y=%f",x,y);}4#includevoidmain(){floatrate,tax,salary;scanf("%f",salary);if(salary<=850)rate=0;elseif(salary>1350&&salary<=2850)rate=0.1;elseif(salary>2850&&salary<5850)rate=0.15;e
10、lserate=0.2;tax=rate*(salary-850);printf("salary=%f,rate=%f,tax=%f",salary,rate,tax);}5#includevoidmain(){inta,b,sum,n;scanf("%d,%d",a,b);sum=a*a+b*b;if(sum>100){n=sum/100;printf("a*a+b*b=%d,n=%d",sum,n);}elseprintf("a*a+b*b=%d",sum);}第6章循环控
11、制一、填空题:1、222、233、464、117二、选择题:1.C2.D3.B4.B5.CB6.C7.C8.C9.DB10.D三、程序阅读:1、输出:332、输出:243、2#4#7#11#16#4、3#2#0#0#1#5、B,A,D,C6、D,A,B,C7、B,C,A,D8、A,D,D,C9、C,C,A10、B,D,A11、BA,D,C四、编程1.#include#includevoidmain(){intx;printf("xsqrt(x)");for(
12、x=5;x<=1000;x++)printf("%d%f",x,sqrt(x));}2.#include#includemain(){inti,flag;doublepi,item;i=1;flag=1;pi=0;item=1.0;while(fabs(item)>=0.00001){item=flag*1.0/i;pi=pi+item;flag=-flag;i=i+2;}pi=pi*4;printf("pi=%f",pi);}3.教材126页例6.84.#