递归
include
int power(int n1, int n2);
int main()
{
int base, powerRaised, result;
printf("基数: ");
scanf("%d",&base);
printf("指数(正整数): ");
scanf("%d",&powerRaised);
result = power(base, powerRaised);
printf("%d^%d = %d", base, powerRaised, result);
return 0;
}
int power(int base, int powerRaised)
{
if (powerRaised != 0)
return (base*power(base, powerRaised-1));
else
return 1;
}