// lab07.cpp
// Foundations 2 - Sect. 2
// October 22, 2004

#include <iostream>
using namespace std;

// function prototype
int *PtrToMax(int *p1, int *p2, int *p3);

int main()
{
  int *a, *b, *c, *ptr;

// Allocate three memory locations for storing three integers,
// and let pointers a, b, and c point to them.

  a = new int;
  b = new int;
  c = new int;
  

  
  cout << "Enter three different integers: " << endl;

// Read three integers and store them in the memory locations
// pointed to by pointers a, b, and c.

  cin >> *a;
  cin >> *b;
  cin >> *c;

  ptr = PtrToMax(a, b, c);
 
// Print the value stored in the memory location pointed
// to by pointer ptr. The value should be the largest of
// three input values.

  cout << endl << endl << "Largest Input: " << *ptr << endl << endl;
  
// Deallocate memory locations pointed to by pointers a,
// b, and c.

   delete a;
   delete b;
   delete c; 
  
  return 0;
}

// function definition
int *PtrToMax(int *p1, int *p2, int *p3)
// returns p1, p2, or p3, whichever points to the largest value
{
 if(*p1 > *p2 && *p1 > *p3)
   return p1;
 else if(*p2 > *p1 && *p2 > *p3)
   return p2;
 else if(*p3 > *p1 && *p3 > *p2)
   return p3;
} 

