#include <iostream>
using namespace std;
long power(long base, long exponent);
int main()
{
int base, exponent;
cout << "请输入底数: ";
cin >> base;
cout << "请输入幂: ";
cin >> exponent;
cout << "积为: " << power(base, exponent);
system("pause");
return 0;
}
long power(long base, long exponent)
{
if (exponent == 1)
{
return base;
}
else
{
return base * power(base, exponent - 1);
}
}
幂指函数的递归实现
最新推荐文章于 2022-11-08 13:17:39 发布