35657

Untitled

Sep 3rd, 2023
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void Degree(int* x, int degree) {
  7.    
  8.     if (degree == 0) {
  9.         *x = 1;
  10.         return;
  11.     }
  12.  
  13.     int a = *x;
  14.  
  15.     for (int i = 0; i < degree - 1; i++) {
  16.         *x *= a;
  17.     }
  18. }
  19.  
  20.  
  21. int main() {
  22.  
  23.     int x = 5;
  24.  
  25.     Degree(&x, 3);
  26.  
  27.     cout << x << endl;
  28.    
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment