题解 | #牛牛的快递#
牛牛的快递
https://www.nowcoder.com/practice/41b42e7b3c3547e3acf8e90c41d98270
#include <stdio.h> int main() { float weight; int fees = 20; /*就算是个空包裹,只要产生订单也要收费*/ char expedited; scanf("%f %c" , &weight, &expedited); if((int)weight < weight) /* 判断是否小数点后有效 */ { fees += weight; /* 利用类型自动转换机制处理首重问题 */ } else { fees += weight-1; /* 重量为整数需要手动减去首重 */ } if(expedited == 'y') { fees += 5; } printf("%d", fees); return 0; }