#include <iostream>
using namespace std;
double mypow (float, int);
int main()
{
int size = 10;
int test[size];
int base;
for (base = -2; base < 4; base += 2)
{
for (int expon = -2; expon < 4; expon += 2)
{
cout << base<< " " << expon << " " << mypow(base, expon) << endl;
}
}
cout << endl;
return 0;
}
double mypow (float num, int raisedTo)
{
int product;
if (raisedTo < 0)
{
for (num = num; num <= raisedTo; num++)
{
product = 1 / (num * num);
}
}
else if (raisedTo == 0)
{
product = 1;
return product;
}
while (num > 0)
{
for (num = num; num <= raisedTo; num++)
{
product = num * num;
return product;
}
}
while (num <= -1)
{
if(raisedTo % 2 == 0)
{
for (num = num; num <= raisedTo; num++)
{
product = num * num;
return product;
}
}
else
for (num = num; num <= raisedTo; num++)
{
product = num * num * -1;
return product;
}
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmRvdWJsZSBteXBvdyAoZmxvYXQsIGludCk7CgppbnQgbWFpbigpCnsKCWludCBzaXplID0gMTA7CglpbnQgdGVzdFtzaXplXTsKCWludCBiYXNlOwoJCglmb3IgKGJhc2UgPSAtMjsgYmFzZSA8IDQ7IGJhc2UgKz0gMikKCXsKCQlmb3IgKGludCBleHBvbiA9IC0yOyBleHBvbiA8IDQ7IGV4cG9uICs9IDIpCgkJewoJCQljb3V0IDw8IGJhc2U8PCAiICAiIDw8IGV4cG9uIDw8ICIgIiA8PCBteXBvdyhiYXNlLCBleHBvbikgPDwgZW5kbDsKCQl9Cgl9CgkKCWNvdXQgPDwgZW5kbDsKCQoJcmV0dXJuIDA7Cn0KCmRvdWJsZSBteXBvdyAoZmxvYXQgbnVtLCBpbnQgcmFpc2VkVG8pCnsKICAgIGludCBwcm9kdWN0OwogICAgCiAgICBpZiAocmFpc2VkVG8gPCAwKQogICAgewogICAgCSBmb3IgKG51bSA9IG51bTsgbnVtIDw9IHJhaXNlZFRvOyBudW0rKykKICAgICAgICAgIHsKICAgICAgICAgICAgICAgcHJvZHVjdCA9IDEgLyAobnVtICogbnVtKTsKICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgCiAgICAgICAgICB9ICAKICAgIAogICAgfQogICAgICAgIAogICAgZWxzZSBpZiAocmFpc2VkVG8gPT0gMCkKICAgIHsKICAgICAgICAgcHJvZHVjdCA9IDE7CiAgICAgICAgIHJldHVybiBwcm9kdWN0OwogICAgfQoKICAgIHdoaWxlIChudW0gPiAwKQogICAgewogICAgICAgICAgCiAgICAgICAgICBmb3IgKG51bSA9IG51bTsgbnVtIDw9IHJhaXNlZFRvOyBudW0rKykKICAgICAgICAgIHsKICAgICAgICAgICAgICAgcHJvZHVjdCA9IG51bSAqIG51bTsKICAgICAgICAgICAgICAgcmV0dXJuIHByb2R1Y3Q7CiAgICAgICAgICB9ICAKICAgIH0KCiAgICB3aGlsZSAobnVtIDw9IC0xKQogICAgewogICAgICAgaWYocmFpc2VkVG8gJSAyID09IDApCiAgICAgICB7CiAgICAgICAgICBmb3IgKG51bSA9IG51bTsgbnVtIDw9IHJhaXNlZFRvOyBudW0rKykKICAgICAgICAgIHsKICAgICAgICAgICAgICBwcm9kdWN0ID0gbnVtICogbnVtOwogICAgICAgICAgICAgIHJldHVybiBwcm9kdWN0OwogICAgICAgICAgfQogICAgICAgfQogICAgICAgZWxzZSAKICAgICAgICAgICBmb3IgKG51bSA9IG51bTsgbnVtIDw9IHJhaXNlZFRvOyBudW0rKykKICAgICAgICAgICB7CiAgICAgICAgICAgICAgIHByb2R1Y3QgPSBudW0gKiBudW0gKiAtMTsKICAgICAgICAgICAgICAgcmV0dXJuIHByb2R1Y3Q7CiAgICAgICAgICAgfQogICAgICAgCiAgICAgICAKICAgIH0KICAgIAogICAgCgkKfQoK