home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / mltiscop / clickme.c next >
C/C++ Source or Header  |  1989-07-28  |  1KB  |  87 lines

  1.  
  2. /*  Logitech MultiScope Debugger Tutorial Program
  3.  *  Copyright (C) 1989 Logitech, Inc.
  4.  *
  5.  *  This is the second C module for TUTOR.C
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <malloc.h>
  10. #include <string.h>
  11. #include <os2def.h>
  12. #define INCL_DOS
  13. #include <bse.h>
  14.  
  15.  
  16. struct DataRec {           
  17.   struct DataRec far *left, far *right;
  18.   int value;
  19.   int uc;
  20.   char dataString[129];
  21. } *root;
  22.  
  23. int count;
  24.  
  25. Insert(rec)
  26. struct DataRec *rec;
  27. {
  28.   struct DataRec *p;
  29.   
  30.   rec->left = NULL;
  31.   rec->right = NULL;
  32.   rec->uc = 0;
  33.   if (!root) {
  34.     root = rec;
  35.     return;
  36.   }
  37.   p = root;
  38.   while (p) {
  39.     if (rec->value < p->value) {
  40.       if (p->left)
  41.         p = p->left;
  42.       else {
  43.         p->left = rec;
  44.         count++;
  45.         return;
  46.       }
  47.     }
  48.     else {
  49.       if (rec->value > p->value) {
  50.         if (p->right)
  51.           p = p->right;
  52.         else { 
  53.           p->right = rec;
  54.           count++;
  55.           return;
  56.         }
  57.       }
  58.       else {
  59.         rec->uc++;
  60.         return;
  61.       }
  62.     }
  63.   }
  64. }
  65.  
  66. Print()
  67. {
  68.   printf("Debuggers over history:\n");
  69.   DoPrint(root);
  70. }
  71.  
  72. DoPrint(p)
  73. struct DataRec *p;
  74. {
  75.   if (p != NULL) {
  76.     DoPrint(p->left);
  77.     DoPrint(p->right);
  78.     printf("%s\n",p->dataString);
  79.   }
  80. }
  81.  
  82. InitInsert()
  83. {
  84.   root = NULL;
  85. }
  86.   
  87.