printf("剩余本金%.2lf\n", benjin - benjin / yue_a * i);
printf("剩余本金%.2lf\n", benjin * (1 - 1 / yue_a * i)); /*这不是数学除法*/
#include#define M 999int main(){ double benjin = 0.0; double lilv = 0.0; double nianxian = 0.0; double benxi_a = 0.0; double lixi_a = 0.0; int yue_a = 0; int i; float yue_benjin = 0.0; double lixi[M] = { 0.0}; printf("请输入本金 年利率 年限\n"); scanf("%lf%lf%lf", &benjin, &lilv, &nianxian); yue_a = nianxian * 12; yue_benjin = benjin /yue_a;#ifdef DEBUG printf("%.2lf\n",yue_benjin);#endif for (i = 0; i < yue_a; ++i) { lixi[i] = (benjin - yue_benjin * i) * lilv /1200;#ifdef DEBUG printf("%.2lf\n",lixi[i]);#endif //printf("第%d个月-应还本金%.2lf\t-应还利息%.2lf\t-剩余本金%.2lf\n", i, yue_benjin, lixi[i], benjin * (1 - 1 / yue_a * i)); /*这不是数学 俩个整数除*/ printf("第%d个月-应还本金%.2lf\t-应还利息%.2lf\t-剩余本金%.2lf\n", i, yue_benjin, lixi[i], benjin - benjin / yue_a * i); lixi_a += lixi[i]; } benxi_a = lixi_a + benjin; printf("总本金[%lf] 总利息[%lf] 总本金利息和[%lf]\n", benjin, lixi_a, benxi_a); return 0;}