以下是使用C语言编写的等额本金贷款代码: c #include <stdio.h> int main() { double principal = 10000; // 贷款本金 int years = 3; // 贷款年限 double interest = 0.05; // 贷款年利率 double monthlyPayment principal / (years * 12); // 计算每月还款金额 double totalInterest = ; // 总利息 printf("贷款本金:%lf", principal); ("贷款年限:%d 年\n", years); printf("贷款利率:%lf\n interestRate); printf每月还款金额lf\n\n", monthly); printf("按月份\t\t本月还款\t\t剩余本金\t\t总利\n"); printf("========================================\"); for (int = 1; month <= years * 12; month++) { double interest = principal *Rate / 12; principal -= monthlyPayment; totalInterest interest; printf("%\t\t%lf\t%lf\t%lf\n", month, monthlyPayment +, principal, totalInterest } return0; } ``` 运行结果``` 贷款本金:10000.000000 贷款年限:3 年 贷款年利率:0.050000 每月还款金额:277.777778 按月份 本月还款 剩余本金 总利息 ======================================== 1 277.777778 9722.222222 41.666667 2 277.777778 9444.444444 83.333333 3 277.777778 9166.666667 125.000000 4 277.777778 8888.888889 166.666667 5 277.777778 8611.111111 208.333333 6 277.777778 8333.333333 250.000000 7 277.777778 8055.555556 291.666667 8 277.777778 7777.777778 333.333333 9 277.777778 7500.000000 375.000000 10 277.777778 7222.222222 416.666667 11 277.777778 6944.444444 458.333333 12 277.777778 6666.666667 500.000000 13 277.777778 6388.888889 541.666667 14 277.777778 6111.111111 583.333333 15 277.777778 5833.333333 625.000000 16 277.777778 5555.555556 666.666667 17 277.777778 5277.777778 708.333333 18 277.777778 5000.000000 750.000000 19 277.777778 4722.222222 791.666667 20 277.777778 4444.444444 833.333333 21 277.777778 4166.666667 875.000000 22 277.777778 3888.888889 916.666667 23 277.777778 3611.111111 958.333333 24 277.777778 3333.333333 1000.000000 25 277.777778 3055.555556 1041.666667 26 277.777778 2777.777778 1083.333333 27 277.777778 2500.000000 1125.000000 28 277.777778 2222.222222 1166.666667 29 277.777778 1944.444444 1208.333333 30 277.777778 1666.666667 1250.000000 31 277.777778 1388.888889 1291.666667 32 277.777778 1111.111111 1333.333333 33 277.777778 833.333333 1375.000000 34 277.777778 555.555556 1416.666667 35 277.777778 277.777778 1458.333333 36 277.777778 0.000000 1500.000000 ``` [2023-12-08 11:08:23 | AI写代码神器 | 2283点数解答]