#include <stdio.h> int main() { float a = 0.0f; char b = 0; int cost = 20; scanf("%f %c", &a, &b); //输入格式两者间要有空格,不然空格会被字符变量吸收导致无法接受'n'或'y' if (a > 1) { if (a == (int)a) cost += a - 1; else cost += a; } if (b == 'y') cost += 5; printf("%d", cost); return 0; }