标签:c
#include<stdio.h>
int main()
{
double function(int n, int k);
int a = 0;
int b = 0;
double c = 0;
scanf("%d %d", &a, &b);
c = function(a, b);
printf("%lf\n", c);
system("pause");
return 0;
}
double function(int n, int k)
{
if (k == 0) //k==0 返回1
{
return 1;
}
else if (k>0) //k>0返回 n的k次方
return n*function(n, k - 1);
else
return 1 / (n*function(n, -k - 1)); //k<0 返回n的k次方
}
本文出自 “零点时光” 博客,请务必保留此出处http://10741764.blog.51cto.com/10731764/1711217
标签:c
原文地址:http://10741764.blog.51cto.com/10731764/1711217