39页第6题 求贷款的金额

 

 

/*计算客户购房办理贷款*/
#include <stdio.h> 
#include <math.h> /*调用函数*/
int main(void) 
{  
    int year;  
    double loan,money,my,rate;
    printf("Enter loan:"); /*输入提示*/
    scanf("%lf",&loan);
    printf("Enter rate:");/*输入提示*/
    scanf("%lf",&rate);
    printf("year money\n"); 
    for(year=5;year<=30;year++){ 
        my=pow(1+rate,12*year);  /*计算指数函数的公式*/
        money=loan*rate*my/(my-1); 
        printf("year=%d money=%.0f\n",year,money); 
    }  
    
    return 0; 
} 

posted @ 2013-10-19 19:11  韵文  阅读(90)  评论(0编辑  收藏  举报