fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double mypow (float, int);
  6.  
  7. int main()
  8. {
  9. int size = 10;
  10. int test[size];
  11. int base;
  12.  
  13. for (base = -2; base < 4; base += 2)
  14. {
  15. for (int expon = -2; expon < 4; expon += 2)
  16. {
  17. cout << base<< " " << expon << " " << mypow(base, expon) << endl;
  18. }
  19. }
  20.  
  21. cout << endl;
  22.  
  23. return 0;
  24. }
  25.  
  26. double mypow (float num, int raisedTo)
  27. {
  28. int product;
  29.  
  30. if (raisedTo < 0)
  31. {
  32. for (num = num; num <= raisedTo; num++)
  33. {
  34. product = 1 / (num * num);
  35.  
  36.  
  37. }
  38.  
  39. }
  40.  
  41. else if (raisedTo == 0)
  42. {
  43. product = 1;
  44. return product;
  45. }
  46.  
  47. while (num > 0)
  48. {
  49.  
  50. for (num = num; num <= raisedTo; num++)
  51. {
  52. product = num * num;
  53. return product;
  54. }
  55. }
  56.  
  57. while (num <= -1)
  58. {
  59. if(raisedTo % 2 == 0)
  60. {
  61. for (num = num; num <= raisedTo; num++)
  62. {
  63. product = num * num;
  64. return product;
  65. }
  66. }
  67. else
  68. for (num = num; num <= raisedTo; num++)
  69. {
  70. product = num * num * -1;
  71. return product;
  72. }
  73.  
  74.  
  75. }
  76.  
  77.  
  78.  
  79. }
  80.  
  81.  
Time limit exceeded #stdin #stdout 5s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty