#include <stdio.h>
//函数声明
double power(double fNumb, int nPow);
void display(double fNumb, int nPow);
int main()
{
display(2.5, 2);
display(1.6, 2);
power(33.33, 2); //这样写,这个语句没有用到,如果你想看这个的值,要将这个赋值给一个变量,再printf出来
double ans = power(33.33, 2);
printf("%lf",ans);
return 0;
}
//函数定义
double power(double fNumb, int nPow)
{
double fRes = 1;
while (nPow--)
fRes *= fNumb;
return fRes;
}
void display(double fNumb, int nPow)
{
double f = power(fNumb, nPow);
printf("%lf的%d次方是:%lf\n", fNumb, nPow, f);
}
错误:
不要分文件写,要写在同一个.cpp文件中,然后建议在main函数前面写函数声明,main函数后面写函数定义