【c语言】购房从银行贷了一笔款d,准本每月还款额为p,月利率为r,计算多少月能还清

// 购房从银行贷了一笔款d,准本每月还款额为p,月利率为r,计算多少月能还清。
// d = 300000  p = 6000  r = 0.01  对求得的月份取小数点后一位,第二位四舍五入
// m = log( p/(p-d*r))/log(1+r)

#include <stdio.h>
#include <math.h>

int main()
{
	float d = 300000.0;
	float p = 6000.0;
	float r = 0.01;
	float m;
	m = log( p / ( p - d * r ) ) / log ( 1 + r );
	printf("需要 %3.1f 个月还清\n",m);

	return 0;
}

<img src="http://img.blog.csdn.net/20150423121336736?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhb3lhcWlhbjU1Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />

文章来自:http://blog.csdn.net/zhaoyaqian552/article/details/45220007
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3