题目:
一只大象口渴了,要喝20升水才能解渴,但现在只有一个深h厘米,底面半径为r厘米的小圆桶(h和r都是整数)。问大象至少要喝多少桶水才会解渴。(设PAI=3.14159)
- 提示信息:“please input the height and the radius:\n”
- 输入格式:"%d,%d"
- 小圆桶的深h,和底面半径r,单位都是厘米。
- 输出格式:"%d"
- 程序运行示例: please input the height and the radius: 23,11 3
程序:
#include <stdio.h>
#define PAI 3.14159
int main()
{
int h,r,n;
printf("please input the height and the radius:\n");
scanf("%d,%d",&h,&r);
n=(20*1000)/(h*r*r*PAI)+1;
printf("%d",n);
return 0;
}
由于单桶体积一定是小数,除不尽,因此只需要取整数部分再加1桶即可。