直接去小数位:强制类型转换
向下取整:#include<math.h>
floor()函数,double float(double x)
向上取整:#include<math.h>
ceil()函数,double ceil(double x)
四舍五入:#include<math.h>
round()函数,double round(double x)
输出的返回值均为double类型,转换为整数需要进行强制转换。
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
double pi = 3.14159;
int all = 20 * 1000;
int main()
{
int h = 0;
int r = 0;
double box = 0;
scanf("%d %d", &h, &r);
box = pi * r * r * h;
printf("%d",(int)ceil(all/box));
return 0;
}