编写x的n次方函数
#include<iostream>
using namespace std;
double power(double x,int n)
{
double a=1.0;
while(n--)
a*=x;
return a;
}
int main()
{
double x;
int n;
cin>>x>>n;
cout<<power(x,n);
return 0;
}
编写x的n次方函数
#include<iostream>
using namespace std;
double power(double x,int n)
{
double a=1.0;
while(n--)
a*=x;
return a;
}
int main()
{
double x;
int n;
cin>>x>>n;
cout<<power(x,n);
return 0;
}