马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
正确结果如下
我自己的代码是这样的#include<stdio.h>
#include<math.h>
int main()
{
float price,area,yir,mir; //单价,面积,年利率,月利率
float interest,loan;//利息,贷款总数
float ave_repay,down_payment;//月均还款,首期付款
float total_price,total_repay;//房款总额,还款总额
int ratio,time;//按揭成数,按揭年数
printf("请输入单价(元/平方):");
scanf("%f",&price);
printf("请输入面积:");
scanf("%f",&area);
printf("请输入按揭成数:");
scanf("%d",&ratio);
printf("请输入按揭年数:");
scanf("%d",&time);
printf("请输入当前基准年利率:");
scanf("%f",&yir);
yir = yir/100;
mir = yir/12;
time = time * 12;
total_price = price * area;
loan = total_price * ratio /10;
down_payment = total_price - loan;
ave_repay = loan * mir * pow((1+mir),time) / (pow((1+mir),time)-1);
total_repay = time*ave_repay;
interest = total_repay - loan;
printf("房款总额:%.2f\n",total_price);
printf("首期付款:%.2f\n",down_payment);
printf("贷款总额:%.2f\n",loan);
printf("还款总额:%.2f\n",total_repay);
printf("支付利息:%.2f\n",interest);
printf("月均还款:%.2f\n",ave_repay);
return 0;
}
结果如下,和正确结果有些不一样
于是我把答案的代码直接复制运行,结果如下,还是和答案不同
请问这是什么原因呢 |