#include<stdio.h> #include<stdlib.h> int n_power_k(int n,int k){ if (k == 0) { return 1; } return n*n_power_k(n,k-1); } int main(){ int n = 2; int k = 5; printf("%d",n_power_k(n,k)); system("pause"); }
C语言用递归实现n^k(不考虑k<0的情况)
猜你喜欢
转载自www.cnblogs.com/Duikerdd/p/9812702.html
今日推荐
周排行