有没有大神看看我哪里错了
我感觉我写的意思一样呀,为啥不对呢 你说的不对是哪里不对?代码也要以文字形式上传。 ba21 发表于 2022-3-13 14:48
你说的不对是哪里不对?
代码也要以文字形式上传。
#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 radio,time;
printf("请输入单价 (元/平方)");
scanf("%f",&price);
printf("请输入面积:");
scanf("%f",&area);
printf("请输入按揭成数:");
scanf("%d",&radio);
printf("请输入按揭年数:");
scanf("%d",&time);
printf("请输入当前基准年利率:");
scanf("%f",&yir);
total_price = price *area;
down_payment = total_price*(1-radio*0.1);
loan = total_price*radio*0.1;
total_repay = (loan*(yir/1200)*pow(1+yir/100/12,time*12)/pow(1+yir/1200,time*12-1))*time*12;
interest = (time*12)*(loan*(yir/1200)*pow(1+yir/100/12,time*12)/pow(1+yir/1200,time*12-1))-loan;
ave_repay = loan*(yir/1200)*pow(1+yir/1200,time*12)/pow(1+yir/1200,time*12-1);
printf("======= 报告结果 =======\n");
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;
} 看看小甲鱼的帖子,
看看小甲鱼的帖子,有助于你更好的提问,同为菜鸟新手的一点帮助吧。 炫笑555 发表于 2022-3-13 14:58
看看小甲鱼的帖子,
看看小甲鱼的帖子,有助于你更好的提问,同为菜鸟新手的一点帮助吧。
谢谢
#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 radio,time;
printf("请输入单价 (元/平方)");
scanf("%f",&price);
printf("请输入面积:");
scanf("%f",&area);
printf("请输入按揭成数:");
scanf("%d",&radio);
printf("请输入按揭年数:");
scanf("%d",&time);
printf("请输入当前基准年利率:");
scanf("%f",&yir);
total_price = price *area;
down_payment = total_price*(1-radio*0.1);
loan = total_price*radio*0.1;
total_repay = (loan*(yir/1200)*pow(1+yir/100/12,time*12)/pow(1+yir/1200,time*12-1))*time*12;
interest = (time*12)*(loan*(yir/1200)*pow(1+yir/100/12,time*12)/pow(1+yir/1200,time*12-1))-loan;
ave_repay = loan*(yir/1200)*pow(1+yir/1200,time*12)/pow(1+yir/1200,time*12-1);
printf("======= 报告结果 =======\n");
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;
}//我的代码
#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);
mir = yir / 100 / 12; // 年利率需要除以100得到,因为用户输入是5.4(%),而不是0.054
time = time * 12;
total_price = price * area;
loan = total_price * ratio / 10; // 这里不能写成(ratio / 10),否则结果会变成0
ave_repay = loan * mir * pow((1 + mir), time) / (pow((1 + mir), time) - 1);
interest = ave_repay * time - loan;
total_repay = loan + interest;
down_payment = total_price * (1 - (float)ratio / 10); // 强制转换ratio为浮点型
printf("========== 报告结果 ==========\n");
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;
}//小甲鱼的
ba21 发表于 2022-3-13 14:48
你说的不对是哪里不对?
代码也要以文字形式上传。
输出结果不对 题中有个条件看错了,我把那个-1添到了指数中了,应该是结果-1 八重神子的狗 发表于 2022-3-13 16:21
题中有个条件看错了,我把那个-1添到了指数中了,应该是结果-1
那就结贴吧 ba21 发表于 2022-3-13 18:33
那就结贴吧
咋结贴呢 老师 八重神子的狗 发表于 2022-3-14 14:25
咋结贴呢 老师
设最佳答案
页:
[1]