//编写一个函数实现n^k,使用递归实现 #include <stdio.h> int cifang( int x, int y )//2^3=2*2*2 { int sum = 0; if( y == 0 ) sum = 1; else sum = x * cifang( x, ( y - 1 ) ); return sum; } int main() { printf("%d\n",cifang( 2,0 )); printf("%d\n",cifang( 3,2 )); printf("%d\n",cifang( 4,1 )); return 0; }
原文地址:http://blog.csdn.net/zhaoyaqian552/article/details/44889767