Saturday, 2 June 2012

C++ Program to display Fibonaccis Heap

C++ Program to display  Fibonaccis Heap


#include <iostream.h>
#include<conio.h>

void main()
{
clrscr();
   unsigned int to,a,n,n1,n2,sum;

   cout << "Enter the limit: n=";
   cin >> to;
   to--;

   n1=n2=1;
   a=2;
   sum=2;

   cout << "Fibonacci's numbers: " << endl;
   cout << "1 1 ";

   while(a<=to)
   {
      n=n1+n2;
      cout << n << " ";
      n1=n2; n2=n;
      sum=sum+n;
      a++;
   }

   cout << endl << endl ;
   cout << "Sum of all numbers= "<< sum << endl;
   getch();
} 

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More