| | |
Really Weird Error... Fibonacci Nums
![]() |
•
•
Join Date: Oct 2004
Posts: 5
Reputation:
Solved Threads: 0
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!
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <ctime> using namespace std; typedef int* IntPtr; long iter(int n) { int a = 1, b = 1; for (int i = 2; i <= n; i++) { int c = a + b; a = b; b = c; } return b; } int optRecur(int n, int array[]) { if (array[n] != 0) return array[n]; if ((n == 0) || (n == 1)) array[n] = 1; else array[n] = optRecur(n-1,array) + optRecur(n-2,array); return array[n]; } void optRecurHelp(int n) { int* a = NULL; a = new int[n]; for(int i = 0; i <= n; ++i) a[i] = 0; optRecur(n,a); delete [] a; a = NULL; } long recur(int n) { if ( n == 0 || n == 1 ) return 1; else return recur(n - 1) + recur(n - 2); } long time(int n, int funct) { double emptyLoop; double j; if(funct == 1) { clock_t start,end; start = clock(); for (int i=0;i<100000000;i++) recur(n); end = clock(); emptyLoop = end-start; double time_passed = static_cast<double>(end-start)/CLOCKS_PER_SEC; j = (((end-start)-emptyLoop)/100000000); } if(funct == 2) { clock_t start,end; start = clock(); for (int i=0;i<100000000;i++) iter(n); end = clock(); emptyLoop = end-start; double time_passed = static_cast<double>(end-start)/CLOCKS_PER_SEC; j = (((end-start)-emptyLoop)/100000000); } if(funct == 3) { clock_t start,end; start = clock(); for (int i=0;i<100000000;i++) optRecurHelp(n); end = clock(); emptyLoop = end-start; double time_passed = static_cast<double>(end-start)/CLOCKS_PER_SEC; j = (((end-start)-emptyLoop)/100000000); } return j; } int main() { int num1; int num2; cout << "What number would you like to compute? " << endl; cin >> num1; cout << "What function (recursive=1, iterative=2, optimized recursive=3)? " << endl; cin >> num2; cout << time(num1,num2) << endl; return 0; }
Last edited by alc6379; Nov 29th, 2004 at 3:02 pm. Reason: added [code] tags
![]() |
Similar Threads
- Getting a weird error (C++)
- Weird error on several PCs, display does not work unless in safe/vga mode win2k (Monitors, Displays and Video Cards)
- Weird Error, Please Help! (Windows NT / 2000 / XP)
- Weird error message and pc wont start at all (Troubleshooting Dead Machines)
- Wierd error messages with calculator program (C++)
- Really Weird error thing. (Windows NT / 2000 / XP)
- WEIRD! php pages do not load unless i hit refresh (PHP)
Other Threads in the C++ Forum
- Previous Thread: help with inputing a string in c
- Next Thread: Size
| Thread Tools | Search this Thread |
api array based binary bitmap business c++ c/c++ char class classes code coding commentinghelp compile console conversion count delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error faq file forms fstream function functions game givemetehcodez graph guess gui hash homeworkhelp homeworkhelper iamthwee ifpug ifstream incrementoperators input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem proficiency program programming project python random read recursion reference rpg string strings temperature template templates test text text-file tree url variable vector video win32 windows winsock word wordfrequency wxwidgets





