C语言入门,代码库,苏小红版第四版C语言程序设计

苏小红版第四版C语言程序设计,第三章习题

//3.2
/*
#include<stdio.h>
#include<math.h>

int main(void)
{
	int a, b, c, x,y;
	printf("Please input a munber:");
	scanf("%d", &x);
	x = (int)fabs(x);         //得x的绝对值
	a = x / 100;			  //计算百位数
	b = (x - a*100) / 10;     //计算十位数
	c = x % 10;               //计算个位数
	y = c * 100 + b * 10 + a;
	printf("%d", y);
	return 0;
}
*/

/*
//3.3
#include<stdio.h>
#include<math.h>

int main(void)
{
	int n;
	double rate = 0.025;
	double capital,deposit;
	printf("Please input capital and n:");
	scanf("%lf,%d", &capital, &n);
	deposit = (1 + rate) * capital;   //计算本金和利息之和
	printf("%lf", deposit);
	return 0;
}
*/
/*
//3.4
#include<stdio.h>
#include<math.h>

int main(void)
{
	float a, b, c, disc, p, q;
	printf("Please enter the coefficients a,b,c:");
	scanf("%f,%f,%f", &a, &b, &c);
	disc = b * b - 4 * a * c;
	p = -b / (2 * a);
	q = sqrt(disc) / (2 * a);
	printf("x1=%7.4f,x2=%7.4f\n", p + q, p - q);
	return 0;

}
*/

//3,5
#include<stdio.h>
#include<math.h>

int main(void)
{
	const double pi = 3.14;
	int r;
	double s, v;
	printf("Please input r:");
	scanf("%d", &r);
	s = 4 * pi * r * r;
	v = 4 / 3 * pi * r * r * r;
	printf("s=%0.2f,v=%0.2f", s, v);
	return 0;

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

花开富贵xxxx

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值