/************************************************************************
ex02.cpp
    driver program to "show off" tstats.h and templates
************************************************************************/
#include <iostream>
#include <time.h>
using namespace std;

#include "tstats.h"

void randomize();
template <class T> void setup(T list[], const int size);
template <class T> void paces(T list[], const int size);

void main() {
    randomize();

    const int maxsize = 100;
    int ilist[maxsize];
    float flist[maxsize];

    setup(ilist, maxsize);
    paces(ilist, maxsize);

    setup(flist, maxsize);
    paces(flist, maxsize);
}
    
void randomize() {
    time_t t;
    srand((unsigned) time(&t));
}

template <class T>
void setup(T list[], const int size) {
    for (int i = 0; i < size; i++)
        list[i] = rand();
}

template <class T>
void paces(T list[], const int size) {
    cout << "The largest element is " << maxof(list, size) << endl
         << "found at element " << indexofmax(list, size) << endl;

    cout << "The average for the list is " << average(list, size) << endl;
    cout << "with a sample deviation of " << stdevs(list, size) << endl;
}