#include<stdio.h>
#include<math.h>
int main()
{
double z,k,x,monthPay,allMoney,temp=0;
int n,i;
printf("輸入借款總額、貸款年限、年利率: ");
//貸款總和最好不要用int型的,int的最大值是32767,那妳豈不是超了
scanf("%lf%d%lf",&z,&n,&k);
//計算n年後要還的總的錢數 pow(x,y)是在頭文件math.h中的函數計算x^y
allMoney = z*pow((1+k/12),12*n);
//式子∑x(1+k/12)^i (i=0,1,2,..,n*12-1)將x提出到前面計算 temp=∑(1+k/12)^i
for(i=0; i<12*n; i++)
temp += pow((1+k/12),i);
//根據等式z(1+k/12)^(12*n) = ∑x(1+k/12)^i (i=0,1,2,..,n*12-1) 得x=allMoney/temp;
x = allMoney/temp;
printf("每月應還款:%lf", x);
}