diff options
author | RossTheRoss <msattr@gmail.com> | 2019-05-09 09:52:15 -0500 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-05-09 09:52:15 -0500 |
commit | ab3cd0211dc0c5bc04fcfe7c49d523a1e8586e4b (patch) | |
tree | 80f7a4ea61cc5876e8f3cdf59a8f9fa06972c267 | |
parent | Remove files not needed in directory (diff) | |
download | homework-ab3cd0211dc0c5bc04fcfe7c49d523a1e8586e4b.tar homework-ab3cd0211dc0c5bc04fcfe7c49d523a1e8586e4b.tar.gz homework-ab3cd0211dc0c5bc04fcfe7c49d523a1e8586e4b.tar.bz2 homework-ab3cd0211dc0c5bc04fcfe7c49d523a1e8586e4b.tar.lz homework-ab3cd0211dc0c5bc04fcfe7c49d523a1e8586e4b.tar.xz homework-ab3cd0211dc0c5bc04fcfe7c49d523a1e8586e4b.tar.zst homework-ab3cd0211dc0c5bc04fcfe7c49d523a1e8586e4b.zip |
M E A N I N G F U L C O M M E N T S
-rw-r--r-- | ee1301/wk7/hw7_directory/strap012_HW7A.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
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 <iostream> #include <fstream> #include <string> @@ -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<length; i++) { for (int j=0; j<length-1; j++) { |