fork download
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3. struct BinaryTree *root=NULL;
  4. struct BinaryTree{
  5. int data;
  6. struct BinaryTree *left;
  7. struct BinaryTree *right;
  8. };
  9.  
  10.  
  11. struct BinaryTree *node(int data)
  12. {
  13. struct BinaryTree *node;
  14. node=(struct BinaryTree*)malloc(sizeof(struct BinaryTree));
  15. node->data=data;
  16. node->left=node->right=NULL;
  17. return node;
  18. }
  19. struct BinaryTree *insert(struct BinaryTree *root,int data1){
  20. if(root==NULL){
  21. root=node(data1);
  22. return root;
  23. }
  24. }
  25. int main() {
  26. root = insert(root,10);
  27. printf("%d",root->data);
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 4392KB
stdin
Standard input is empty
stdout
10