Paste Search Dynamic
Recent pastes
myPow
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. double myPow(double x, int n) {
  4.     if (n == int_max) return x;
  5.     else if (n == int_min) return (x == 1 || x == -1) ? 1 : 0;
  6.     if(n<0) x=1/x, n*=-1;
  7.     double ans = 1;
  8.     for(int i=0;i<n;i++)
  9.         ans = ans*x;
  10.     return ans;
  11. }
  12. int main(){
  13.     cout<<myPow(2, 10);
  14. }
Parsed in 0.002 seconds