[置顶] C语言实验:等额本金还款法的计算

海萍夫妇为了彻底告别“蜗居”生活,痛下决心贷款60万元购买了一套三居室 。若贷款月利率为0.5%,还款期限为120个月,还款方式为等额本金还款法(即贷款期限内每期以相等的额度偿还贷款本金,贷款利息随本金逐期递减)。试求出每个月还款的本金、每个月的利息以及总利息分别是多少元。

这题相当无趣,权当娱乐了各位!

下面是代码,仅供参考:

#include <stdio.h>

int main()
{
    float b=0,d=0;
    for(int m=1; m<=120; m++)
    {
        b=(600000-5000*m)*0.005;
        d=d+b;
        printf("The %3d times of the repayment of interest is ¥%-7.2f ",m,b);
        printf("The principal is ¥5000\n");
    }
    printf("The total accrual is ¥%.2f\n",d);
}
原文地址:https://www.cnblogs.com/xinyuyuanm/p/2992054.html