用switch case 匹配
#include <iostream>
using namespace std;
double choose(int x)
{
switch (x)
{
case 1:
return 4;
case 2:
return 4.5;
case 3:
return 5;
case 4:
return 2;
case 5:
return 1.5;
default:
return 0;
}
}
int main()
{
int x,y;
cin >> x >> y;
double res = 0;
res += choose(x) * y;
printf("Total: R$ %.2lf",res);
return 0;
}