Really Weird Error... Fibonacci Nums

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2004
Posts: 5
Reputation: lostinthespiral is an unknown quantity at this point 
Solved Threads: 0
lostinthespiral lostinthespiral is offline Offline
Newbie Poster

Really Weird Error... Fibonacci Nums

 
0
  #1
Nov 29th, 2004
I'm having some real problems with a code that is supposed to find Fibonacci numbers using recursive, iterative, and optimized recursive techniques. I keep on getting this really strange error though: "fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 1786) Please choose the technical Support command on the Visual C++ Help menu, or open the technical Support help file for more information Error executing cl.exe.". If anyone could think of some advice, it would be really helpful. Thanks!

  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. using namespace std;
  5.  
  6. typedef int* IntPtr;
  7.  
  8. long iter(int n)
  9. {
  10. int a = 1, b = 1;
  11. for (int i = 2; i <= n; i++)
  12. {
  13. int c = a + b;
  14. a = b;
  15. b = c;
  16. }
  17. return b;
  18. }
  19.  
  20. int optRecur(int n, int array[])
  21. {
  22. if (array[n] != 0)
  23. return array[n];
  24. if ((n == 0) || (n == 1))
  25. array[n] = 1;
  26. else
  27. array[n] = optRecur(n-1,array) + optRecur(n-2,array);
  28. return array[n];
  29. }
  30.  
  31. void optRecurHelp(int n)
  32. {
  33. int* a = NULL;
  34. a = new int[n];
  35. for(int i = 0; i <= n; ++i)
  36. a[i] = 0;
  37. optRecur(n,a);
  38. delete [] a;
  39. a = NULL;
  40. }
  41.  
  42. long recur(int n)
  43. {
  44. if ( n == 0 || n == 1 )
  45. return 1;
  46. else
  47. return recur(n - 1) + recur(n - 2);
  48. }
  49.  
  50. long time(int n, int funct)
  51. {
  52. double emptyLoop;
  53. double j;
  54.  
  55. if(funct == 1)
  56. {
  57. clock_t start,end;
  58. start = clock();
  59. for (int i=0;i<100000000;i++)
  60. recur(n);
  61. end = clock();
  62. emptyLoop = end-start;
  63. double time_passed = static_cast<double>(end-start)/CLOCKS_PER_SEC;
  64. j = (((end-start)-emptyLoop)/100000000);
  65. }
  66. if(funct == 2)
  67. {
  68. clock_t start,end;
  69. start = clock();
  70. for (int i=0;i<100000000;i++)
  71. iter(n);
  72. end = clock();
  73. emptyLoop = end-start;
  74. double time_passed = static_cast<double>(end-start)/CLOCKS_PER_SEC;
  75. j = (((end-start)-emptyLoop)/100000000);
  76. }
  77. if(funct == 3)
  78. {
  79. clock_t start,end;
  80. start = clock();
  81. for (int i=0;i<100000000;i++)
  82. optRecurHelp(n);
  83. end = clock();
  84. emptyLoop = end-start;
  85. double time_passed = static_cast<double>(end-start)/CLOCKS_PER_SEC;
  86. j = (((end-start)-emptyLoop)/100000000);
  87. }
  88. return j;
  89. }
  90.  
  91. int main()
  92. {
  93. int num1;
  94. int num2;
  95.  
  96. cout << "What number would you like to compute? " << endl;
  97. cin >> num1;
  98. cout << "What function (recursive=1, iterative=2, optimized recursive=3)? " << endl;
  99. cin >> num2;
  100. cout << time(num1,num2) << endl;
  101. return 0;
  102. }
Last edited by alc6379; Nov 29th, 2004 at 3:02 pm. Reason: added [code] tags
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 18
Reputation: big146 is an unknown quantity at this point 
Solved Threads: 0
big146's Avatar
big146 big146 is offline Offline
Newbie Poster

Re: Really Weird Error... Fibonacci Nums

 
0
  #2
Nov 29th, 2004
Try removing optimazation options 0g/ 0i/ 0a. Remove one at a time to see wich one might be the culprit.
big146
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 5
Reputation: lostinthespiral is an unknown quantity at this point 
Solved Threads: 0
lostinthespiral lostinthespiral is offline Offline
Newbie Poster

Re: Really Weird Error... Fibonacci Nums

 
0
  #3
Nov 29th, 2004
Tried. Fixed. Still get the same error.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC