From 912dbb8f9851410dedee012ac023d7b53cb9bf5f Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Fri, 9 Dec 2016 23:54:01 +0800 Subject: [PATCH] Create 1899.cpp --- QUSTOJ/1899.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 QUSTOJ/1899.cpp diff --git a/QUSTOJ/1899.cpp b/QUSTOJ/1899.cpp new file mode 100644 index 0000000..a32f7ff --- /dev/null +++ b/QUSTOJ/1899.cpp @@ -0,0 +1,42 @@ +#include +#include +#include +#include +using namespace std; + +struct btree +{ + btree* l; + btree* r; + char v; +}; + +btree _node; +btree* root=&_node; + +int counter=0; + +void deal(btree* n) +{ + scanf("%c",&n->v); + if(n->v=='#') + { + n->l=n->r=NULL; + return ; + } + else + { + n->l=new btree; + deal(n->l); + n->r=new btree; + deal(n->r); + if(n->l->v=='#'&&n->r->v=='#') ++counter; + } +} + +int main() +{ + deal(root); + printf("%d\n",counter); + return 0; +}