Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int liczba;
- int potega;
- void wczytaj()
- {
- cout << "Podaj liczbe: ";
- cin>>liczba;
- cout << "Podaj potege: ";
- cin>>potega;
- }
- void potegowanie(int l,int p)
- {
- float s=1;
- if(p>0)
- {
- for(int i=1;i<=p;i++)
- {
- s=s*l;
- }
- cout<<"Wynik: "<<s<<endl;
- }
- else if(p==0){cout<<"Wynik: "<<s<<endl;}
- else
- {
- for(int i=-1;i>=p;i--)
- {
- s=s*l;
- }
- float w=1.0/s;
- cout<<"Wynik: "<<(float)w<<endl;
- }
- }
- int main()
- {
- wczytaj();
- potegowanie(liczba,potega);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement