Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int* tab;
- int n;
- int t;
- void print( int n)
- {
- for(int i=0; i<n; i++)
- {
- cout << tab[i] << " ";
- }
- }
- void drzewko ( int previous, int index)
- {
- if ( index==n )
- { cout<<endl;
- print (n);
- return;
- }
- else
- {
- for( int i= previous + 1 ; i<=1+index*t; i++)
- {
- tab[index]=i;
- previous=i;
- drzewko(previous,index+1);
- }
- }
- }
- int main()
- {
- cout<<"Program generujacy Z-postac drzew t-narnych"<<endl;
- cout<<"Prosze podac stopien t: t=";
- cin>>t;
- cout<<"Prosze podac liczbe wierzcholkow wewnetrznych: n=";
- cin>>n;
- tab=new int[n];
- int index=1;
- tab[0]=1;
- drzewko(1,index);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement