Obliczanie potęgi w C++

[code=cpp]#include #include #include #include using namespace std; float potega(float x, int n) { if (n==0) return 1; else return potega(x, n-1)*x; } int main() { int x, n; cout«“Podaj podstawe potegi: “; cin»x; cout«“Podaj wykladnik potegi: “; cin»n; cout«potega(x,n); getchar(); cin.ignore(); return 0; }[/code]

[code=cpp]#include #include #include #include

using namespace std;

float potega(float x, int n) { if (n==0) return 1; else return potega(x, n-1)*x; }

int main() { int x, n; cout«“Podaj podstawe potegi: “; cin»x; cout«“Podaj wykladnik potegi: “; cin»n; cout«potega(x,n); getchar(); cin.ignore(); return 0; }[/code]