I can't find what is wrong in my program. Is somebody who knows ?.
#include <iostream>
#include <conio.h>
#include <time.h>
#include <cstdlib>
#include <iomanip>
using namespace std;
long double fibo [100]; int n;
double czas;
clock_t start,stop;
int main ();
int f( int n)
{
int main();
start=clock();
if (n==0) return 3;
else return f(n-1)+2;
stop=clock();
cout<<"Czas zapisu:"<<czas<<"s "<<endl;
return (0);
}
Siema! Your program doesn't make much sense. The main function is only declared, but never defined. You never assign anything to your czas variable, but attempt to print it. All the code after your if-else return statements is inaccessible.
Your program really makes no sense. This is nowhere near a proper fibonacci sequence, if that's what you're going for.
#include <iostream>
//#include <conio.h>
#include <ctime>
#include <cstdlib>
#include <iomanip>
usingnamespace std;
// long double fibo [100]; // not used
int f(int n) // still not the fibonacci sequence, but at least it compiles
{
if (n == 0)
return 3;
elsereturn f(n-1) + 2;
}
int main()
{
clock_t start, stop;
start = clock(); // not actually used in a meaningful way
int czas = f(3); // I decided to call your function with n = 3
cout << "Czas zapisu: " << czas << "s "<< endl;
stop = clock(); // not actually used in a meaningful way
return 0;
}