题解 | #牛牛的快递#
牛牛的快递
https://www.nowcoder.com/practice/41b42e7b3c3547e3acf8e90c41d98270
#include <stdio.h>
#include <math.h>
int main() {
float a = 0;
char ch;
int price = 0;
scanf("%f %s",&a,&ch);
if(a <= 1.0)
{
switch (ch)
{
case 'y': price = 20 + 5;
break;
case 'n': price = 20;
break;
}
printf("%d\n",price);
}
else if(a>1)
{
switch(ch)
{
case 'y': price = ceil(a - 1) * 1 + 20 + 5;//ceil(x)返回不小于x的最小整数值(然后转换为double型)。
break;
case 'n': price = ceil(a - 1) * 1 + 20;
break;
}
printf("%d\n",price);
}
return 0;
}