数学中幂的递归

写给自己看的
在这里插入图片描述

#include<iostream>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<ctime>
#include<stdio.h>
#include<stdlib.h>
#include "这是声明类的头文件.h"
using namespace std;



int __power__(int p[],int base,int index); 



int main()
{

	int p[5];
	
	p[0] = 2;
	p[1] = 3;
	p[2] = 2;
	p[3] = 1;
	p[4] = 1;
	
	
	printf("%d\n",__power__(p,0,1));




	return 0;
}



int __power__(int p[],int base,int index)
{
	if(1 == p[index])
	{
		return p[base];
	}
	else
	{
		return pow(p[base],__power__(p,base+1,index+1));
	}
	
}

注:1.有问题百度一下
2.解决不了的,看马克思哲学
3.本人老师是宝哥

发布了17 篇原创文章 · 获赞 1 · 访问量 296

猜你喜欢

转载自blog.csdn.net/xjlovewjh/article/details/103443435