题解 | #牛牛的快递#
牛牛的快递
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; }