求教:分期贷款时间求解代码,输出数值不对
//分期付款时间求解代码#include<stdio.h>
#include<math.h>
int main(void)
{
/*int all,perm;
float lx,m;
all = 324500;
perm = 3245;
lx = 0.008 ;
m = (log10(perm)-log10(perm-all*lx))/log10(1+lx);
printf("The right time will be month = %d \n",m);
return 0;*/
int d,p;
double r,m;
d=324500;
p=3245;
r=0.008;
m=(log10(d)-log10(p-d*r))/log10(1+r);
printf("The right time will be month = %f .\n",m);
printf("The total money will be Total= %f\n",m*p);
return 0;
}
输出值为:
The right rime will be month = 799.929190 .
The total money will be Total = 2530870.220799
Press any key to continue
这是我编写的代码和教材上的代码输出的结果。
但是教材上的输出结果为:
month = 201.983404
total = 655436.127930
求教我的程序编写哪里出错了?为什么编译没有问题但是输出结果不对呢?