题解 | #牛牛的水杯#

牛牛的水杯

https://www.nowcoder.com/practice/c196c47c23394bf3bdd4f82a838df6bf

#include <limits.h>
#include <stdio.h>
#include<math.h>
int main() {
    int h,r;
    scanf("%d%d",&h,&r);
    float v=3.14*h*r*r;
    float p=(int)(10000.0/v);//10L=10000ml   ml和cm等价
    if(10000.0/v==p)//if((int)(10000.0/v==p))错,不加int
    {
        printf("%d\n",(int)(10000.0/v));//要%d和int
    }
    else {
    printf("%d\n",(int)(10000.0/v)+1);//要%d和int
    }

    return 0;
}

全部评论

相关推荐

我就是0offer糕手:北大不乱杀
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务