mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1899.cpp
This commit is contained in:
parent
695de53630
commit
912dbb8f98
42
QUSTOJ/1899.cpp
Normal file
42
QUSTOJ/1899.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user