题解 | #牛牛的快递#

牛牛的快递

https://www.nowcoder.com/practice/41b42e7b3c3547e3acf8e90c41d98270

#include<stdio.h>
#include<stdbool.h>
bool integer(float input)
{
    int a=(int)input;
    return a==input;
}
int main()
{
    float weight=0.0;
    char yesorno;
    float addweight=0.0;
    int price=0;
    scanf("%f %c",&weight,&yesorno);
    if(weight<=1)
    {
        if(yesorno=='y')
        price=25;
        else
        price=20;
    }
    else if(weight>1)
    {
        if(integer(weight))
        {
            if(yesorno=='y')
            price=25+1*(weight-1);
            else
            price=20+1*(weight-1);
        }
        else
        {
            if(yesorno=='y')
            price=25+1*(weight-1)+1;
            else
            price=20+1*(weight-1)+1;
        }
    }
    printf("%d",price);
    return 0;
}

全部评论

相关推荐

群星之怒:不是哥们,你就不好奇瘫痪三十年的老植物人是啥样的吗?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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