注册 登录
编程论坛 C++教室

练习题,帮我看看对吗?

JXZJH 发布于 2011-09-19 23:46, 521 次点击
1假如我国国民生产总值的年增长率为10%,计算10年后我国国民生产总值与现在相比增长多少百分比。
计算公式为
p=(1+r)n(是n次方)
r为年增长率;n为年数;p为与现在相比的百分比。
看这样写对吗?
#include<stdio.h>
#include<math.h>
void main()
{
    double r=0.1,n=1.0,p;
    p=pow((1+r),n);
    printf("p=%f\n",p);
}
2 回复
#2
jcw081201102011-09-20 08:30
程序代码:
#include<stdio.h>
#include<math.h>
void main()
{
    double r=0.1,n=10.0,p;// 这里你的n  10
    p=pow((1+r),n);
    printf("p=%f\n",p);
}
#3
lucky5635912011-09-20 09:03
纯数学问题,与编程无关
1