35657

Untitled

Jul 22nd, 2023
1,114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int power(int a, int n) {
  5.     if (n == 0) {
  6.         return 1;
  7.     }
  8.     return a * power(a, n - 1);
  9. }
  10.  
  11. int main() {
  12.     setlocale(LC_ALL, "ru");
  13.     int a, n;
  14.     cout << "Введите число: ";
  15.     cin >> a;
  16.     cout << "Введите степень: ";
  17.     cin >> n;
  18.     cout << power(a, n);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment