#include <stdio.h> int main() { float weight; int price; char ji; scanf("%f %c",&weight,&ji); if(weight<=1)//重量小于1kg { if(ji=='y') { price=20+5; } else { price=20; } }else {//重量大于1kg weight=weight-1;//price=20 if(weight<(int)weight+1 &&weight>(int)weight)//判断四舍五入 { weight++; } if(ji=='y') { price=20+5+(int)weight; }else { price=20+(int)weight; } } printf("%d",price); return 0; }