Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
pow implementation
//Title of this code #include <iostream> using namespace std; // http://stackoverflow.com/questions/5231096/time-complexity-of-power int power(int a, int b) { int pow = 1; while ( b ) { if ( b & 1 ) { pow = pow * a; --b; } a = a*a; b = b/2; } return pow; } int mypow(int a, int b) { int ret = 1; for (int i = 0; i < b; ++i) ret *= a; return ret; } int main() { std::cout << power(2,10); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
My billing system
always_late
copy_30-Seconds-of-C++
decrypt_problem_5
KhadijahAlshehhi
Handling new types without using RTTI
多态
Exploring the Transform Function and Operator Classes
Kth Smallest Element (with extra space)
Find value in sorted matrix
Please log in to post a comment.