power calculation - library kullanilamadigi durumlarda
#include "stdafx.h"
int powx(int x, int y); // calculates x^y
int _tmain(int argc, _TCHAR* argv[])
{
int test = powx(5, 3); // would return 25
return 0;
}
int powx(int x, int y) // calculates x^y
{
int base=x, res=1;
while(y)
{
if(y&1)
res *= base;
y>>=1;
base *= base;
}
return res;
}