注册 登录
编程论坛 C语言论坛

新手求助,购票金额为什么为0,这种方法写错在哪里

xjxjxj 发布于 2022-07-07 15:06, 1069 次点击
double calculate_price(i)
{
    double money;
    if(i > 0 && i < 30)
    {
        money = 50 * i;
        //printf("购票金额为: %lf \n",money);
    }
    else
    {
        money = (50 * i) - (i*2);
        //printf("购票金额为: %lf \n",money);
    }

    return 0;
}

int main()
{
    int a;
    int price;

    printf("请输入购买的票数:\n");
    scanf("%d", &a);
    //calculate_price(a);
    price = calculate_price(a);
    printf("购票金额为: %d \n",price);

    return 0;
}
/*

 variable 'money' set but not used [-Wunused-but-set-variable]|
 
*/
2 回复
#2
xjxjxj2022-07-07 15:16
已找到
#3
wp2319572022-07-08 07:32
return 0
1