#include<bits/stdc++.h>
using namespace std;
class node{
public:
int data;
node* left;
node* right;
node(int d){
data=d;
left=NULL;
right=NULL;
}
};
void create(node* &root){
int d;
cin>>d;
root=new node(d);
string left,right;
cin>>left;
if(left=="true"){
//cin>>d;
//root->left=new node(d);
create(root->left);
}
if(left=="false"){
root->left=NULL;
}
cin>>right;
if(right=="true"){
//cin>>d;
//root->right=new node(d);
create(root->right);
}
if(right=="false"){
root->right=NULL;
}
}
void sibling (node* root){
if(!root->left && !root->right){
cout<data;
return;
}
// if(root==NULL){
// return;
// }
sibling(root->left);
sibling(root->right);
return;
}
int main(){
node* root=NULL;
create(root);
sibling(root);
return 0;
}
it shows segmentation fault