c程序设计第四版谭浩强
3.1 假如我国国民生产总值的年增长率为10%,计算10年后我国国民生产总值与现在相比增长多少百分比。
计算公式为P=(1+r)^n,r为年增长率;n为年数;P为与现在相比的百分比。
【c源程序】
#include <stdio.h>
#include <math.h>
int main()
{float p,r,n;
r=0.1; //如果年增长率为9%,就改为r=0.09
n=10;
p=pow(1+r,n);
printf("p=%f\n",p);
return 0;
}
本文链接:http://www.wb98.com/c/post/tanhaoqiang_3.1.html
本站文章搜索: