35657

Untitled

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