Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int power(int a, int n) {
- if (n == 0) {
- return 1;
- }
- return a * power(a, n - 1);
- }
- int main() {
- setlocale(LC_ALL, "ru");
- int a, n;
- cout << "Введите число: ";
- cin >> a;
- cout << "Введите степень: ";
- cin >> n;
- cout << power(a, n);
- }
Advertisement
Add Comment
Please, Sign In to add comment