题解 | #牛牛的水杯#
牛牛的水杯
https://www.nowcoder.com/practice/c196c47c23394bf3bdd4f82a838df6bf
#include <stdio.h>
int main() {
int h, r;
float c;
scanf("%d %d",&h,&r);
c=10000.0/(3.14*h*r*r);
if(((((int)(c*100))%100)||(((int)(c*10))%10))!=0)
{
c++;
printf("%d",(int)c);
}
else
printf("%d",(int)c);
return 0;
}
确保c小数点后两位都不为0就可以用如3.02 4.20 。3.004就不能用了
这道题这种方法可用
