#include<stdio.h>
#include<math.h>
//power函数
double power(double x,double y);
int main()
{
double x = 2.0, y = 3.0, z;
z = power(x, y);
printf("%f\n",z);
while (1);
return 0;
}
double power(double x, double y)
{
double z = 1.0;
while (y)
{
z =z*x;
--y;
}
return z;
}
结果:
时间: 2024-10-19 00:13:57