谁能告诉我错在哪里,我刚学函数,我觉得是调用函数用错了
//计算正整数的n次方
#include <stdio.h>
int fu ( int a ); //处理负数的函数
long int xtothen ( int x, int n); //处理计算n次方的函数
int result, x, n;//x为底数,n为指数
int i = 1;//i 做循环用
int main (void)
{
printf ("输入你想要的值( x n ): \n");
scanf ("%i%i", &x, &n);
printf ( "result is = %i\n", xtothen (x, n));
return 0;
}
long int xtothen ( int x, int n)//处理计算n次方的函数
{
x = fu ( x);
n = fu ( n);
result = 1;
if ( x = 0 )
printf ("error 底数等于0\n");
else if ( x != 0 && n == 0 )
result = 1;
else
while ( i <= n )
result *= x;
return result;
}
int fu ( int a)//处理负数的函数
{
if ( a < 0 )
{
a = -a;
printf (" 输入的负数已经当作正数处理了\n");
}
else
a = a;
return a;
}