#include <stdio.h>
#include <stdlib.h>

float best(float values[], int length, int (*better)(float a, float b))
{
  float good = values[0];
  int i;
  for (i = 1; i < length; i++) {
    if ((*better)(values[i], good))
      good = values[i];
  } /* for */
  return good;
} /* best*/

int flt(float x, float y)
{
  return (x < y);
} /* flt(int, int) */

int fgt(float x, float y)
{
  return (x > y);
} /* fgt(int, int) */

main()
{
  float alpha[] = { 5.0, 1.0, 6.0, 7.0, 9.0 };

  printf("The smallest value in alpha is: %f\n", best(alpha, 5, flt));
  printf("The largest value in alpha is: %f\n", best(alpha, 5, fgt));
  exit(EXIT_SUCCESS);
} /* main() */
