编写计算X的N次乘方的程序

来源:百度知道 编辑:UC知道 时间:2024/05/26 11:27:06
#include<stdio.h>
main()
{
int x,y,n;
if(x=0);
printf("Error.NO");
else
if(x!=0&&n=0)
printf("S=1",S);
else
power(float x,int n)
}

power(int a,int b)
{while(b)
{t=1;
t=t*a;
b--;
return t}
}
程序错误
我是初学者,详细帮我讲一下

不明白加我百度HI
#include<stdio.h>
int power(int a,int b) ;
void main()
{
int x,n;
scanf("%d %d",&x,&n);
if(x==0)
printf("Error.NO\n");
else if(x!=0&&n==0)
printf("S=1");
else
printf("%d\n",power(x,n) );
}

int power(int a,int b)
{
int t=1;
while(b)
{
t=t*a;
b--;
}
return t;
}

不明白???全英文~~~~~~~~~~~~~~~~~~~饿