Advertisement
STANAANDREY

sb prog 30

Mar 4th, 2022
1,151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. float putere(int a, int n) {
  5.     if (n > 0) {
  6.         return a * putere(a, n - 1);
  7.     }
  8.     if (n < 0) {
  9.         return 1 / putere(a, -n);
  10.     }
  11.     return 1;
  12. }
  13.  
  14. int main() {
  15.     int a, n;
  16.     cin >> a >> n;
  17.     cout << putere(a, n) << endl;
  18.     return 0;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement