题解 | #取近似值#

取近似值

https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a

#include <stdio.h>

int main() {
    float x;
    scanf("%f",&x);
    float temp=0.0;
    for(float i=1.0;i<x;i++)
        temp+=1.0;
    x=x-temp;
    if(x>=0.5)
       printf("%d",(int)(temp+1));//类型转换
    else
       printf("%d",(int)(temp));
}

全部评论

相关推荐

饼子吃到撑:据我了解奥,我身边的护士大部分都是找关系进的医院,还掏了不少米
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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