编写一个接受正整数n的C函数并返回2^n。陈述任何假设。查找电源
所以这是正确的....?
#include<math.h>
double power(int x)
{
int i,pow,n, ans;
ans=1;
printf ("Enter the number and power:");
scanf ("%d%d", &pow, &n);
for(i=1;i<=pow; i++)
{
ans = ans *n
return pow(2,n);
}
int main()
{
int x, y,c;
c=pow(x,y);
printf("%d to the power %d is %d",n,pow,ans);
getch();
}
已经试过了么?有一个简单的函数原型,但没有实际的代码来执行任务...你到目前为止尝试过什么? SO不是关于我们做你的功课... – NirMH