题解 | #牛牛的水杯#
牛牛的水杯
http://www.nowcoder.com/practice/c196c47c23394bf3bdd4f82a838df6bf
#include<stdio.h>
int main(){
//1L水=1000立方厘米
//10L水=10000立方厘米
//一杯水的体积为s*h
//s = Π*r*r;
float s = 0;
float v = 0;
int h = 0;
int r = 0;
float n = 0;
scanf("%d %d",&h,&r);
s = 3.14*r*r;//水杯底面积
v = s*h;//水杯体积,单位为立方厘米
n = 10000.0f/v;
if(n-(int)n == 0)
printf("%d",(int)n);
if(n-(int)n != 0)
printf("%d",(int)n+1);
return 0;
}