From ab3cd0211dc0c5bc04fcfe7c49d523a1e8586e4b Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Thu, 9 May 2019 09:52:15 -0500 Subject: M E A N I N G F U L C O M M E N T S --- ee1301/wk7/hw7_directory/strap012_HW7A.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'ee1301/wk7/hw7_directory') diff --git a/ee1301/wk7/hw7_directory/strap012_HW7A.cpp b/ee1301/wk7/hw7_directory/strap012_HW7A.cpp index fc63bbf..5b9ffc4 100644 --- a/ee1301/wk7/hw7_directory/strap012_HW7A.cpp +++ b/ee1301/wk7/hw7_directory/strap012_HW7A.cpp @@ -1,3 +1,9 @@ +//Matthew Strapp +//EE1301 +//HW7A: The house database +//8 May 2019 + + #include #include #include @@ -66,8 +72,8 @@ int main(int argc, char* argv[]) { houseData* currentZipFind = head; - int zipSort[1000]; bool newZip=true; int currentUnique=0; - for (int i=0; i<999; i++) {zipSort[i]=0;} + int zipSort[10000]; bool newZip=true; int currentUnique=0; + for (int i=0; i<9999; i++) {zipSort[i]=0;} while(currentZipFind!=nullptr) { for (int i=0; i<999; i++) { //Find a new zipcode to average @@ -85,15 +91,15 @@ int main(int argc, char* argv[]) { } currentZipFind = currentZipFind->nextZip; } - bsort(zipSort, 1000); //Sort array of zipcodes by bubblesort. + bsort(zipSort, 10000); //Sort array of zipcodes by bubblesort. houseData* findAvg = head; - int costPerZip[1000]={0}, totalPerZip[1000]={0}; + int costPerZip[10000]={0}, totalPerZip[10000]={0}; //Set all of the values to zero - for (int i=0; i<999; i++) {costPerZip[i]=0; totalPerZip[i]=0;} + for (int i=0; i<9999; i++) {costPerZip[i]=0; totalPerZip[i]=0;} while (findAvg!=nullptr) { - for(int j=0; j<999; j++) { + for(int j=0; j<9999; j++) { if (zipSort[j]==findAvg->zipcode) { costPerZip[j]+=findAvg->price; totalPerZip[j]++; @@ -102,7 +108,7 @@ int main(int argc, char* argv[]) { } //end for findAvg=findAvg->nextZip; } //end while - for (int k=0; k<999; k++) { + for (int k=0; k<9999; k++) { if (zipSort[k]!=0) { cout << zipSort[k] << ":average price=" << costPerZip[k]/totalPerZip[k] << endl; } @@ -138,7 +144,7 @@ void ProcHeader(ifstream &file) { } } -//This function is the algorithm. +//Bubble sort the zipcode algorithm void bsort(int list[], int length) { for (int i=0; i