#include <iostream>

using namespace std;

struct brTree {
    char data;
    brTree *lchild;
    brTree *rchild;
};

void creatTree(brTree *&tree)
{
    char c;
    cin >> c;
    if (c == '#')
    {
        tree = NULL;
    }
    else
    {
        tree = new brTree;
        tree->data = c;
        creatTree(tree->lchild);
        creatTree(tree->rchild);
    }
}


void getTree(brTree *tree, int &count)
{
    if (tree == NULL)
    {
        return;
    }
    if (tree->rchild != NULL)
    {
        count++;
        getTree(tree->rchild, count);
    }
}



int main()
{
    brTree *tree = NULL;
    creatTree(tree);

    int count = 0;

    getTree(tree, count);

    cout << count+1;

    return 0;
}
最后修改:2019 年 04 月 10 日 06 : 00 PM
如果觉得我的文章对你有用,请随意赞赏