aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk7/hw7_directory
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-05-09 09:50:07 -0500
committerRossTheRoss <msattr@gmail.com>2019-05-09 09:50:07 -0500
commit9478bfe7e6be4c12de437b04f3d0d3cf27f1945e (patch)
tree4d5ac7bd9ad9fbf150ec80450fb912e0b6262dbe /ee1301/wk7/hw7_directory
parentE again (diff)
downloadhomework-9478bfe7e6be4c12de437b04f3d0d3cf27f1945e.tar
homework-9478bfe7e6be4c12de437b04f3d0d3cf27f1945e.tar.gz
homework-9478bfe7e6be4c12de437b04f3d0d3cf27f1945e.tar.bz2
homework-9478bfe7e6be4c12de437b04f3d0d3cf27f1945e.tar.lz
homework-9478bfe7e6be4c12de437b04f3d0d3cf27f1945e.tar.xz
homework-9478bfe7e6be4c12de437b04f3d0d3cf27f1945e.tar.zst
homework-9478bfe7e6be4c12de437b04f3d0d3cf27f1945e.zip
I have the big stupid
(FINISH FINAL HW OF EE1301)
Diffstat (limited to 'ee1301/wk7/hw7_directory')
-rw-r--r--ee1301/wk7/hw7_directory/strap012_HW7A.cpp11
1 files changed, 5 insertions, 6 deletions
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;
}
}