#include<iostream> #include<cstdlib> using namespace std; int count=0; typedef struct node { char data; struct node *l,*r; }Tree; void Init(Tree *&T) { char str; cin>>str; if(str!='#') { T=(Tree *)malloc(sizeof(Tree)); T->data=str; Init(T->l); Init(T->r); } else T=NULL; } int Dot(Tree *&T) { if(T!=NULL) { if(T->l==NULL && T->r==NULL) count++; //叶节点,即最底层 Dot(T->l); Dot(T->r); } return count; } int main() { Tree *T; Init(T); cout<<Dot(T); return 0; }