From 9478bfe7e6be4c12de437b04f3d0d3cf27f1945e Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Thu, 9 May 2019 09:50:07 -0500 Subject: I have the big stupid (FINISH FINAL HW OF EE1301) --- ee1301/wk7/hw7_directory/strap012_HW7A.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ee1301') diff --git a/ee1301/wk7/hw7_directory/strap012_HW7A.cpp b/ee1301/wk7/hw7_directory/strap012_HW7A.cpp index eb1ff8f..fc63bbf 100644 --- a/ee1301/wk7/hw7_directory/strap012_HW7A.cpp +++ b/ee1301/wk7/hw7_directory/strap012_HW7A.cpp @@ -85,17 +85,16 @@ int main(int argc, char* argv[]) { } currentZipFind = currentZipFind->nextZip; } - bsort(zipSort, 1000); + bsort(zipSort, 1000); //Sort array of zipcodes by bubblesort. houseData* findAvg = head; int costPerZip[1000]={0}, totalPerZip[1000]={0}; //Set all of the values to zero for (int i=0; i<999; i++) {costPerZip[i]=0; totalPerZip[i]=0;} - while (findAvg!=NULL) { + + while (findAvg!=nullptr) { for(int j=0; j<999; j++) { - if (zipSort[j]=findAvg->zipcode) { - cout << zipSort[j] << " " << findAvg->zipcode << endl; - cout << j << endl; + if (zipSort[j]==findAvg->zipcode) { costPerZip[j]+=findAvg->price; totalPerZip[j]++; break; //Break for loop @@ -105,7 +104,7 @@ int main(int argc, char* argv[]) { } //end while for (int k=0; k<999; k++) { if (zipSort[k]!=0) { - cout << zipSort[k] << ":average price=" << totalPerZip[k] << endl; + cout << zipSort[k] << ":average price=" << costPerZip[k]/totalPerZip[k] << endl; } } -- cgit v1.2.3