Please send questions to
st10@humboldt.edu .
#include <iostream>
#include <iomanip>
#include "binSearch.h"
using namespace std;
//**************************************************
// Contract: main : void -> int
// Purpose: test binSearch on its given Examples
//
// Examples: not really applicable; simply runs
// the function on a hard-coded array
// and prints the results
//
// by: Sharon M. Tuttle
// last modified: 11-17-03
//***************************************************
int main()
{
int arr1[] = {1, 3, 8, 27, 56, 77, 78, 79, 100};
cout << "binSearch(arr1, 50, 0, 8) s.b. -1: "
<< setw(2) << binSearch(arr1, 50, 0, 8) << endl;
cout << "binSearch(arr1, 150, 0, 8) s.b. -1: "
<< setw(2) << binSearch(arr1, 150, 0, 8) << endl;
cout << "binSearch(arr1, 0, 0, 8) s.b. -1: "
<< setw(2) << binSearch(arr1, 0, 0, 8) << endl;
cout << "binSearch(arr1, 1, 0, 8) s.b. 0: "
<< setw(2) << binSearch(arr1, 1, 0, 8) << endl;
cout << "binSearch(arr1, 100, 0, 8) s.b. 8: "
<< setw(2) << binSearch(arr1, 100, 0, 8) << endl;
cout << "binSearch(arr1, 56, 0, 8) s.b. 4: "
<< setw(2) << binSearch(arr1, 56, 0, 8) << endl;
return 0;
}