友友们这个问题我只会写一半,帮我看下接下来怎么写吧

这个我只会写一半,后面不会了,也看不懂了,和循环结构有关的🤔

img

img

#include <stdio.h>
#include <math.h>

int main()
{
float total_cost, annual_salary, portion_saved;
printf(“请输入总房价:”);
scanf("%f", &total_cost);
printf(“请输入年薪:”);
scanf("%f", &annual_salary);
printf(“请输入月存款比例:”);
scanf("%f", &portion_saved);
portion_saved /= 100; // 转换为百分比

// 根据首付款比例计算首付款金额和每个月需要存款数额
float down_payment = total_cost * 0.3;
float monthly_deposit = annual_salary * portion_saved / 12;

printf("首付 %.2f 元\n", down_payment);
printf("月存款 %.2f 元\n", monthly_deposit);

// 计算多少个月才能存够首付款,结果为整数,不足1月按1个月计算,即向上取整
int number_of_months = ceil(down_payment / monthly_deposit);
printf("需要%d个月可以存够首付\n", number_of_months);

return 0;
}

参考
https://blog.csdn.net/weixin_60530224/article/details/130671080