1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 14:36:19 +00:00
202401-programming-assignments/【实践课内】2.选择结构1/7-5 计算油费.c

33 lines
470 B
C

#include <stdio.h>
const double P90 = 6.95;
const double P93 = 7.44;
const double P97 = 7.93;
int main() {
int a, b;
char c;
scanf("%d %d %c", &a, &b, &c);
double ans = a;
if (b == 90) {
ans *= P90;
} else if (b == 93) {
ans *= P93;
} else { // b == 97
ans *= P97;
}
if (c == 'm') {
ans *= 0.95;
} else { // c == 'e'
ans *= 0.97;
}
printf("%.2lf\n", ans);
return 0;
}