當前位置:外匯行情大全網 - 貸款諮詢 - C語言題:某客戶為購房辦理商業貸款,選擇了按月等額本息還款方式,計算公式如下?在貸款本金(loan

C語言題:某客戶為購房辦理商業貸款,選擇了按月等額本息還款方式,計算公式如下?在貸款本金(loan

#include?<stdio.h>

float?cal_power(float?x,?int?n)

{

float?p=1.0;

while(n>0)?{

p=p*x;

n--;

}

return?p;

}

float?cal_money(int?loan,?float?rate,?int?month)

{

double?tmp;

tmp=cal_power(1+rate,month);

return?loan*rate*tmp/(tmp-1);

}

int?main(void)

{

int?loan,year,month;

float?money,rate;

printf("Enter?loan:?");

scanf("%d",&loan);

printf("Enter?rate:?");

scanf("%f",&rate);

for(year=5;year<=30;year++)?{

month=12*year;

money=cal_money(loan,rate,month);

printf("money(%d,%d)=%.0f\n",loan,year,money);

}

return?0;

}

  • 上一篇:江蘇蘇浩投資集團有限公司怎麽樣?
  • 下一篇:口袋妖怪在下壹次攻擊中能擊中什麽水果?
  • copyright 2024外匯行情大全網