AcWing 660. 零食

nighty_k 2022-01-07 20:01:21 阅读数:701

acwing 零食

鏈接
https://www.acwing.com/problem/content/662/

思路
小學計算題

//法1
#include <cstdio>
int main()
{

int x, y;
scanf("%d%d", &x, &y);
double price[5] = {
4.00, 4.50, 5.00, 2.00, 1.50};
printf("Total: R$ %.2lf",price[x - 1] * y);
return 0;
}
//法2
#include <cstdio>
int main()
{

int x, y;
scanf("%d%d", &x, &y);
double price;
if (x == 1) price = 4;
else if (x == 2) price = 4.5;
else if (x == 3) price = 5;
else if (x == 4) price = 2;
else price = 1.5;
printf("Total: R$ %.2lf\n", price * y);
return 0;
}
版权声明:本文为[nighty_k]所创,转载请带上原文链接,感谢。 https://gsmany.com/2022/01/202201072001206477.html