fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int x, n, z=1;
  7. int sum=0;
  8.  
  9. cout << "Podaj x: ";
  10. cin >> x;
  11. cout << "Podaj n: ";
  12. cin >> n;
  13.  
  14. for (int i=0;i<n; i++){
  15. sum=0;
  16. for (int j=0;j<z;j++)
  17. sum+=x;
  18. z = sum;
  19. }
  20.  
  21. cout << "Wynik potegowania to: " << sum;
  22. return 0;
  23. }
Success #stdin #stdout 0s 16048KB
stdin
3 2
stdout
Podaj x: Podaj n: Wynik potegowania to: 9