Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- double a;
- int n;
- double TinhLuyThua(double A,int N)
- {
- if (N==1)
- {
- return A;
- }
- else
- {
- int temp = TinhLuyThua(A,N/2);
- if (N%2==0)
- {
- return temp*temp;
- }
- else
- return temp*temp*A;
- }
- }
- int main()
- {
- cout<<"Nhap co so a: ";
- cin>>a;
- cout<<"Nhap so mu n: ";
- cin>>n;
- cout<<"Luy thua la: "<<TinhLuyThua(a,n)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement