fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. struct node
  8. {
  9. int data;
  10. struct node* left;
  11. struct node* right;
  12. };
  13.  
  14. struct node* newNode(int data)
  15. {
  16. struct node* new_node=(struct node*)malloc(sizeof(struct node));
  17. new_node->data=data;
  18. new_node->left=NULL;
  19. new_node->right=NULL;
  20. return new_node;
  21. }
  22.  
  23. void inorder(struct node* root)
  24. {
  25. if(root==NULL) return;
  26.  
  27. inorder(root->left);
  28. cout<<root->data;
  29. inorder(root->right);
  30. }
  31. int main() {
  32.  
  33. struct node* root = newNode(1);
  34. root->left= newNode(2);
  35. root->right= newNode(3);
  36. root->left->left= newNode(4);
  37. root->left->right= newNode(5);
  38.  
  39. inorder(root);
  40. //mirror(root);
  41. //inorder(root);
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
42513