求X的N次乘方

float power(float x,int n)
{
 float t=1;
 for(int i=1;i<=n;i++)
   t=t*x;                                      /*1*x*x*x*...*x共乘n次*/
 return t;
}

#include <stdio.h>
#include 
<conio.h>
float power(float,int);
void main()
{
 
float x,t;
 
int n;
 clrscr();
 printf(
"Please input x,n number:");
 scanf(
"%f,%d",&x,&n);
 t
=power(x,n);
 printf(
"The max number is :%6.2f",t);
}


float power(float x,int n)
{
 
float t=1;
 
for(int i=1;i<=n;i++)
   t
=t*x;
 
return t;
}

posted @ 2007-01-13 11:07  齐心  Views(445)  Comments(0Edit  收藏  举报