Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int* tab;
  6. int n;
  7. int t;
  8.  
  9. void print( int n)
  10. {
  11. for(int i=0; i<n; i++)
  12. {
  13. cout << tab[i] << " ";
  14. }
  15. }
  16.  
  17. void drzewko ( int previous, int index)
  18. {
  19. if ( index==n )
  20. { cout<<endl;
  21. print (n);
  22. return;
  23. }
  24. else
  25. {
  26. for( int i= previous + 1 ; i<=1+index*t; i++)
  27. {
  28. tab[index]=i;
  29. previous=i;
  30. drzewko(previous,index+1);
  31. }
  32. }
  33. }
  34.  
  35. int main()
  36. {
  37. cout<<"Program generujacy Z-postac drzew t-narnych"<<endl;
  38. cout<<"Prosze podac stopien t: t=";
  39. cin>>t;
  40. cout<<"Prosze podac liczbe wierzcholkow wewnetrznych: n=";
  41. cin>>n;
  42.  
  43. tab=new int[n];
  44. int index=1;
  45. tab[0]=1;
  46. drzewko(1,index);
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement