1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include "mylist.h"
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main(void)
{
const int ARRAY1 = 1;
const int ARRAY2 = 2;
cout << "const int ARRAY1 = 1;" << endl;
cout << "const int ARRAY2 = 2;" << endl;
MyList list;
cout << "list.printArray(ARRAY1 ,20, false); " << endl;
cout << "About to print the content of myIntArray, 20 values per line, in regular order" << endl
<< "Should show 1000 nines, 20 per line" << endl;
list.printArray(ARRAY1, 20, false); //print content of myIntArray, 20 values per line, in regular order
cout << "list.printArray(ARRAY2 ,20,false); " << endl;
cout << "About to print the content of myCopyArray, 20 values per line, in regular order" << endl
<< "should show 50 zeros, 20 per line" << endl;
list.printArray(ARRAY2, 20, false); //print content of myArrayCopy, 20 values per line, in regular order
cout << "list.printArray(98, 20, false); " << endl;
cout << "About to print the content of an array 98, 20 values per line, in regular order." << endl
<< "Problem is, there are only two options for the first parameter, 1 or 2" << endl
<< "Should default to myIntArray and show 1000 nines, 20 per line" << endl;
list.printArray(98, 20, false); //print content of array 98, 20 values per line, in regular order Problem is, there are only two options for first parameter, 1 or 2
cout << "list.plainCopy(); " << endl;
cout << "About to copy the first 50 elements of myIntArray to myCopyArray" << endl;
list.plainCopy();
cout << "list.printArray(ARRAY2 ,10,false);" << endl;
list.printArray(ARRAY2, 10, false);
cout << "About to print the content of myCopyArray, 10 values per line, in regular order" << endl;
int multiple = 400;
cout << " " << endl;
int total = list.sum(multiple); //this is saying to sum myIntArray[0], myIntArray[400], myIntArray[800]
cout << "The sum of values for positions that are multiples of " << multiple << " is: " << total << endl;
multiple = 100;
cout << "The sum of values for positions that are multiples of " << multiple << " is: " << list.sum(multiple) << endl; //sums positions [0], [100], [200], [300], [400], [500], [600], [700], [800],[900],
list.reset();
list.printArray(ARRAY1, 20, true);
int numValuesToInsert = 5;
bool result = list.promptAndInsert(ARRAY2, numValuesToInsert);
if (result) //can also be written as if(result == true)
cout << "Insert successful!" << endl;
else
cout << "Insert failed...try again."
<< "Cannot insert " << numValuesToInsert << " into array." << endl;
numValuesToInsert = 400; //this should cause the function to return false if it is passed to array 2.
if (list.promptAndInsert(ARRAY2, numValuesToInsert) == true)
cout << "Insert successful!" << endl;
else
cout << "Insert failed...try again."
<< "Cannot insert " << numValuesToInsert << " into array." << endl;
cout << "About to compare both arrays. Each match should be shown with the value and location within the arrays" << endl;
list.compareArrays();
return 0;
}
|