Advertisement
SergeyPGUTI

6.2.2

Nov 20th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. double mult(double a,int n)
  7. {
  8.     if (n<0) { a=1.0/a;
  9.                n=-n;          
  10.              }
  11.     if (n>=1)
  12.         return a*mult(a,n-1);
  13.     else
  14.         return 1;
  15. }
  16.  
  17. int main()
  18. {
  19.     double a;
  20.     int n;
  21.     cin>>a>>n;
  22.     cout<<mult(a,n);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement