#include <stdio.h>
int main(void)
{
    double total_price =0;
    int type =0;
    int number =0;
    const double type1_price =3.5;
    const double type2_price =5.5;
    printf("Please choose the type (1 or 2): \n");
    scanf("%d",&type);
    printf("Enter the number: ");
    scanf("%d",&number);
    total_price = number * (type1_price + (type -1)*(type2_price-type1_price));
    printf("You choose %d of type %d ,and shold pay $%.2f .\n",number ,type ,total_price);
    return 0;
}
这是书上给出的答案,供大家参考一下,我认为,是我把问题想的太复杂了,走了岔路