Advertisement
NuquernaNarsil

Rekurencja_1_35_43_b_podr

Sep 25th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. double n=0,i=0;
  7.  
  8. double ciag (double n)
  9. {
  10.     if (n==1)
  11.         return 0.5;
  12.     if (n==2)
  13.         return 1;
  14.     if (n>2)
  15.         return 3*ciag(n-2)+ciag(n-1);
  16. }
  17.  
  18. main()
  19. {
  20.     cout <<"Podaj ilosc liczb z ciagu, ktora cie interesuje: ";
  21.     cin >> n;
  22.     cout <<"Podane liczby to : ";
  23.     for (i=1;i<=n;i++)
  24.         cout << ciag(i) <<", ";
  25. getch();
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement