Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/06/2012, 12:47
Avatar de W_NEMESIS
W_NEMESIS
 
Fecha de Ingreso: mayo-2012
Ubicación: pasto
Mensajes: 25
Antigüedad: 12 años
Puntos: 1
Exclamación problema con arbol binario

me da 2 errores

21 `main' must return `int'
Build Error] ["arbol binario.o"] Error 1

ayuda no se q hacerle

Código C++:
Ver original
  1. #include<iostream.h>
  2. #include<conio.h>
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5. struct node
  6.     {
  7.     int data;
  8.     node *left;
  9.     node *right;
  10.     };
  11.  
  12. node *tree=NULL;
  13. node *insert(node *tree,int ele);
  14.  
  15. void preorder(node *tree);
  16. void inorder(node *tree);
  17. void postorder(node *tree);
  18. int count=1;
  19.  
  20. void main()
  21.     {
  22.     system("cls");
  23.     int ch,ele;
  24.     do
  25.         {
  26.         system("cls");
  27.         cout<<"\n\t\a\a1----INSERT A NODE IN A BINARY TREE.\a\a";
  28.         cout<<"\n\t\a\a2----PRE-ORDER TRAVERSAL.\a\a";
  29.         cout<<"\n\t\a\a3----IN-ORDER TRAVERSAL.\a\a";
  30.         cout<<"\n\t\a\a4----POST-ORDER TRAVERSAL.\a\a";
  31.         cout<<"\n\t\a\a5----EXIT.\a\a";
  32.         cout<<"\n\t\a\aENTER CHOICE::\a\a";
  33.         cin>>ch;
  34.         switch(ch)
  35.             {
  36.             case 1:
  37.             cout<<"\n\t\a\aENTER THE ELEMENT::\a\a";
  38.             cin>>ele;
  39.             tree=insert(tree,ele);
  40.             break;
  41.              
  42.             case 2:
  43.             cout<<"\n\t\a\a****PRE-ORDER TRAVERSAL OF A TREE****\a\a";
  44.             preorder(tree);
  45.             break;
  46.            
  47.             case 3:
  48.             cout<<"\n\t\a\a****IN-ORDER TRAVERSAL OF A TREE****\a\a";
  49.             inorder(tree);
  50.             break;
  51.            
  52.             case 4:
  53.             cout<<"\n\t\a\a****POST-ORDER TRAVERSAL OF A TREE****\a\a";
  54.             postorder(tree);
  55.             break;
  56.            
  57.             case 5:
  58.             exit(0);
  59.             }
  60.         }while(ch!=5);
  61.     }
  62.  
  63. node *insert(node *tree,int ele)
  64. {
  65.     if(tree==NULL)
  66.         {
  67.         tree=new node;
  68.         tree->left=tree->right=NULL;
  69.         tree->data=ele;
  70.         count++;
  71.         }
  72.     else
  73.     if(count%2==0)
  74.     tree->left=insert(tree->left,ele);
  75.     else
  76.     tree->right=insert(tree->right,ele);
  77.     return(tree);
  78. }
  79.  
  80. void preorder(node *tree)
  81. {
  82.     if(tree!=NULL)
  83.     {
  84.         cout<<tree->data;
  85.         preorder(tree->left);
  86.         preorder(tree->right);
  87.         getch();
  88.     }
  89. }
  90.    
  91. void inorder(node *tree)
  92. {
  93.     if(tree!=NULL)
  94.     {
  95.         inorder(tree->left);
  96.         cout<<tree->data;
  97.         inorder(tree->right);
  98.         getch();
  99.     }
  100. }
  101.  
  102. void postorder(node *tree)
  103. {
  104.     if(tree!=NULL)
  105.     {
  106.         postorder(tree->left);
  107.         postorder(tree->right);
  108.         cout<<tree->data;
  109.         getch();
  110.     }
  111. }