#include <iostream> using namespace std; int getpower(int x, int y) { if (y < 0) return 0; else if (y == 0) return 1; else if (y == 1) return x; else return x*getpower(x, y - 1); } double getpower(double x, double y) { if (y == -1) return 1.0 / x; else if (y == 0) return 1; else if (y == 1) return x; else if (y > 1) return x * getpower(x, y - 1); else if (y < -1) return 1.0/x * getpower(x, y + 1); } int main() { int x, y; cin >> x >> y; cout << getpower(x, y); double a, b; cin >> a >> b; cout << getpower(a, b); return 0; }
标签:return,int,double,else,打卡,5.19,getpower From: https://www.cnblogs.com/Sunyiran/p/17415784.html