Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- char vivesti(int arrayInt, char symbol, int i){
- while(i < arrayInt){
- cout << symbol << vivesti(arrayInt, symbol, i+1);
- cout << "1";
- }
- }
- void buildBody(int x, char symbol, int i){
- vivesti(x, symbol, i);
- cout << "4";
- cout << "*";
- }
- char buildTree(int userNumber, int i, char symbol){
- if(i >= userNumber){
- i = 0;
- symbol = ' ';
- buildBody(userNumber, symbol, i);
- }else{
- if(i < userNumber*2){
- symbol = ' ';
- int x = userNumber - (i/2);
- cout << "0";
- vivesti(x, symbol, i);
- symbol = '*';
- x = i+1;
- vivesti(x, symbol, i);
- cout << "2";
- cout << endl;
- cout << "3";
- return buildTree(userNumber, i+2, symbol);
- }
- }
- }
- int main()
- {
- int userNumber,i = 0;
- char symbol;
- cout << " Enter number to build a tree - ";
- cin >> userNumber;
- cout << endl;
- buildTree(userNumber, i, symbol);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement