After emailing my instructor it seems I am supposed to generate the list as follows
list[0] = 25.88 - sqrt(0) = 25.88
list[1] = 25.88 - sqrt(1) = 24.88
list[2] = 25.88 - sqrt(2) = 24.4658
however I am having issues getting my program running. I get this error and am not sure what to make of it
Error 1 error C2676: binary '[' : 'orderedArrayListType<elemType>' does not define this operator or a conversion to a type acceptable to the predefined operator
The code that generates said error is this:
-
#include "stdafx.h"
-
#include <iostream>
-
#include "orderedArrayListType.h"
-
#include <time.h>
-
#include <math.h>
-
using namespace std;
-
-
//double sqrt(double, double);
-
-
int _tmain(int argc, _TCHAR* argv[])
-
{
-
double i;
-
-
int maxSize;
-
-
cout << "Please enter the size of the list: 10, 100 or 1000"<<endl;
-
cin >> maxSize; //User determined size of list
-
-
cout<<"Testing selection sort!!!"<<endl;
-
orderedArrayListType<int>list(maxSize);
-
cout<<"Size of list = "<<list.maxListSize();
-
-
for(i = 0; i < maxSize; i++)
-
{
-
list[i] = 25.88 - sqrt(i);
-
}
-
-
cout<<"The list before sorting:"<<endl;
-
list.print();
-
cout<<endl;
-
-
list.selectionSort();
-
-
cout<<"The list after sorting:"<<endl;
-
list.print();
-
cout<<endl;
-
-
cout << "Selection sort: Number of comparisons = "<<list.getSortComparisons()<<endl;
-
cout << "Selection sort: Number of swaps = "<<list.getSortSwaps()<<endl;
-
cout<<endl;
-
-
-
return 0;
-
}
-
The specific line where the problem is
-
for(i = 0; i < maxSize; i++)
-
{
-
list[i] = 25.88 - sqrt(i);
-
}
-