PiotrJurek

Zad9

Mar 29th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. float POTEGA(float x,float y)
  6. {
  7. float wynik = 1;
  8. if(y<0)
  9. {
  10. for (int i=0; i>y; i--)
  11. {
  12. wynik/=x;
  13. }
  14. }
  15. else
  16. {
  17. for (int i=0; i<y; i++)
  18. {
  19. wynik*=x;
  20. }
  21. }
  22. return wynik;
  23. }
  24.  
  25. int main()
  26. {
  27. cout << POTEGA(-10, 3) << endl;
  28. cout << POTEGA(5, 4) << endl;
  29. cout << POTEGA(0, 0) << endl;
  30. cout << POTEGA(-2, -2) << endl;
  31. cout << POTEGA(-2, -3) << endl;
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment