Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.222.163.134
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/vnlaughlin/../rnlink/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/vnlaughlin/../rnlink/stutreeclient2.cpp
// stutreeclient.cpp - test client for gradetree class

#include "stutree.h"
#include <iostream>
using namespace std;

//---------------------------------------------------------------------------
int main()
{
   int sum = 0, num = 0;
   float avg = 0;
   Gradetree grades;

   // First, add some unique grades

   grades.Insert (5);
   grades.Insert (4);
   grades.Insert (3);
   grades.Insert (6);
   grades.Insert (8);
   grades.Insert (5);

   // Display picture of tree

   cout << "\n\nAfter adding 5, 4, 3, 6, 8, 5";
   cout << "\nSideways 'picture' of the tree:\n\n";
   grades.TreePicture ();

   // Next, add some duplicate grades

   grades.Insert (6);
   grades.Insert (5);
   grades.Insert (4);

   // Make sure tree structure is still the same

   cout << "\n\nAfter adding duplicate 6, 5, 4";
   cout << "\nSideways 'picture' of the tree:\n\n";
   grades.TreePicture ();

   // Display the traversals

   cout << "\nTree Traversals:";
   cout << "\n PRE: ";
   grades.Preorder ();
   cout << "\nPOST: ";
   grades.Postorder ();
   cout << "\n  IN: ";
   grades.Inorder ();

   sum = grades.SumGrades();
   cout << "\n\nThe sum of the grades is: " << sum << endl;

   num = grades.NumGrades();
   cout << "\n\nThe number of grades is: " << num << endl;

   avg = grades.AvgGrade();
   cout << "\n\nThe average grade is: " << avg << endl;

   cout << "\n\n";

   return 0;

}





Stv3n404 - 2023