From 7d96aa052c954f851ad33f18af0b281c0fc055c1 Mon Sep 17 00:00:00 2001 From: Jesus Hilario Hernandez Date: Sat, 13 Jun 2020 04:20:35 -0500 Subject: [PATCH] modified --- .../Programming Challenges/14.cpp | 16 +++++++++------- .../Programming Challenges/17.cpp | 12 ++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Chapter-7-Arrays/Review Questions and Exercises/Programming Challenges/14.cpp b/Chapter-7-Arrays/Review Questions and Exercises/Programming Challenges/14.cpp index 6269ba8..708e094 100644 --- a/Chapter-7-Arrays/Review Questions and Exercises/Programming Challenges/14.cpp +++ b/Chapter-7-Arrays/Review Questions and Exercises/Programming Challenges/14.cpp @@ -26,13 +26,14 @@ **/ #include #include + using namespace std; void getUserNumbers(int[], const int); void findDuplicateNumbers(vector &); -void getMatchingDigits(vector, +void getMatchingDigits(const vector, vector &, const int[], int &, @@ -44,6 +45,7 @@ void displayInfo(const int[], const int, const int); + int main() { const int ARRAY_SIZE = 5; @@ -56,8 +58,8 @@ int main() getUserNumbers(user_numbers, ARRAY_SIZE); for (int i = 0; i < ARRAY_SIZE; i++) - duplicate_numbers.push_back(user_numbers[i]); - + duplicate_numbers.push_back(user_numbers[i]); // 5 5 7 8 9 + findDuplicateNumbers(duplicate_numbers); getMatchingDigits(duplicate_numbers, @@ -65,7 +67,7 @@ int main() lottery_numbers, total_matching_digits, ARRAY_SIZE); - + displayInfo(user_numbers, lottery_numbers, matching_digits, @@ -73,7 +75,7 @@ int main() ARRAY_SIZE); return 0; -} +} // End int main() void getUserNumbers(int user_numbers[], const int ARRAY_SIZE) { @@ -114,7 +116,7 @@ void findDuplicateNumbers(vector &duplicate_numbers) } } -void getMatchingDigits(vector duplicate_numbers, +void getMatchingDigits(const vector duplicate_numbers, vector &matching_digits, const int lottery_numbers[], int &total_matching_digits, @@ -161,4 +163,4 @@ void displayInfo(const int user_numbers[], if(total_matching_digits == ARRAY_SIZE) cout << "You are the grand prize winner!!" << endl; -} \ No newline at end of file +} diff --git a/Chapter-7-Arrays/Review Questions and Exercises/Programming Challenges/17.cpp b/Chapter-7-Arrays/Review Questions and Exercises/Programming Challenges/17.cpp index b1b9db2..4176cae 100644 --- a/Chapter-7-Arrays/Review Questions and Exercises/Programming Challenges/17.cpp +++ b/Chapter-7-Arrays/Review Questions and Exercises/Programming Challenges/17.cpp @@ -28,10 +28,10 @@ using namespace std; -void readFileContentsIntoVector(vector &, string); +void readFileContentsIntoVector(vector &, const string); void showMenu(); -bool checkIfValueInVector(vector, string); -void displayIfAmongMostPopular(vector, string); +bool checkIfValueInVector(const vector, const string); +void displayIfAmongMostPopular(const vector, const string); int inputValidate(int); void program(const vector, const vector); @@ -110,7 +110,7 @@ int inputValidate(int number) } -void readFileContentsIntoVector(vector &vector, string file_name) +void readFileContentsIntoVector(vector &vector, const string file_name) { ifstream inputFile; @@ -147,7 +147,7 @@ void showMenu() } -bool checkIfValueInVector(vector vector, string value) +bool checkIfValueInVector(const vector vector, const string value) { bool value_exists = false; for(int i = 0; i < vector.size(); i++) @@ -159,7 +159,7 @@ bool checkIfValueInVector(vector vector, string value) return value_exists; } -void displayIfAmongMostPopular(vector vector, string name) +void displayIfAmongMostPopular(const vector vector, const string name) { cout << endl << name