- 1、本文档共29页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
谭浩强版C语言前5章习题(答案)
第二章
1.x++,3x1,Xf_1_4,a$#24,bg—1,I am不是标识符
3.1)2L转换成float类型,3转换成float型,012转换成float类型,44转换成float类型;
2)34转换成double类型,sqrt(34)转换成int类型,6转换成double类型,5转换成double类型,3*(int)sqrt(34)转换成double类型,0x2AF转换成double类型;
3)4转换成float类型,2.5f+4转换成double类型,6转换成Long类型,6*27L转换成double类型,1526转换成double,2.4L转换成double
4.1)
#include stdio.h
int main()
{
printf(%f\n,3*(2L+4.5f)-012+44);
return 0;
} 53.
2) #include stdio.h
#include math.h
int main()
{
printf(%f\n,3*(int)sqrt(34)-sin(6)*5+0x2af);
return 0;
} 703.
3)#include stdio.h
#include math.h
int main()
{
printf(%f\n,cos(2.5f+4)-6*27L+1526-2.4L);
return 0;
} 1362.
6. #include stdio.h
double weight(double p,double d)
{
return p*3.*d*d*d/6.0;
}
int main()
{
printf(the weight of iron is :%f\n,weight(7.86,0.1));
printf(the weight of gold is :%f\n,weight(19.3,0.15));
return 0;
} 铁:0. 金:0.
7. #include stdio.h
#include math.h
int main()
{
int a,b,c,d;
double s,x1,x2;
printf(please input three numbers:);
scanf(%d,%d,%d,a,b,c);
d=b*b-4*a*c;
if(d0)
{
s=sqrt(d);
x1=(-b+s)/2.0/a;
x2=(-b-s)/2.0/a;
printf(the result is:%f,%f\n,x1,x2);
}
else if(d==0)
{
x1=-b/2.0/a;
printf(the result is:%f\n,x1);
}
else
printf(error!\n);
return 0;
} error!
第三章
4.调用f函数时,1转换成float类型,第一个y转换成int型,函数体中n,4转换成float型,结果由float转换成Int型
6.
圆球体积:
double sphere_volume(double radius)
{
return 3.14159*4*radius*radius*radius/3;
}
圆球表面积:
double sphere_area(double radius)
{
return 3.14159*4*radius*radius;
}
圆柱体体积:
double cylinder_volume(double radius,double height)
{
return 3.14159*radius*radius*height;
}
圆柱体表面积:
double cylinder_area(double radius,double height)
{
return 2*3.14159*radius*radius+2*3.14159*radius*height;
}
7.1)全部用printf()输出
2)
#include stdio.h
double weight(double y,double x)
{
return y*3.*x*x*x/6.0;
}
int main()
{
printf(the weight of gold is :%f\n,weight(7.86,0.1));
printf(the weight of silver is :%f\n,weight(19.3,0.15));
printf(the weight of copper is :%f\n,weight(7.86,0.1));
printf(the weight of iron is
您可能关注的文档
最近下载
- 6天河区绿化养护第三方监督评价工作要求1.DOC
- 苏教版四年级下册数学期末试卷4套(完美版).pdf
- 实验三比值控制实验2.doc
- 【设施和环境条件管理程序】2023年医学实验室管理体系认证审核资料(内含表格).docx VIP
- 2023-2024学年《监督学》试卷及答案解析.pdf VIP
- 标准图集-浙J44《住宅防火型变压式排气道》.pdf
- 八年级物理:时间和长度的测量练习题含答案.pdf
- 【生物安全管理程序】2023年医学实验室管理体系认证审核资料(内含表格检查表).docx VIP
- 【仪器设备校准和检定管理程序】2023年医学实验室管理体系认证审核资料(内含全套表格).docx VIP
- 《运用“思维导图”提高中年级习作水平的研究策略》课题研究方案.docx
文档评论(0)