#include using namespace std; // TOO MANY BRUTE FORCE FUNCTIONS!!!!!!! void PrintArray(const int* array, unsigned int size); void PrintArrayPositives(const int* array, unsigned int size); void PrintArrayNegatives(const int* array, unsigned int size); void PrintArrayOdds(const int* array, unsigned int size); void PrintArrayEvens(const int* array, unsigned int size); void PrintArrayDivis3(const int* array, unsigned int size); int main() { int list[15] = {-2, 5, 0, 14, 123, -67, -90, 85, 32, 200, 50, -21, 80, 77, -123}; cout << "Print the array:\n"; PrintArray(list, 15); cout << "\nPrint the positive elements of the array:\n"; PrintArrayPositives(list, 15); cout << "\nPrint the negative elements of the array:\n"; PrintArrayNegatives(list, 15); cout << "\nPrint the odd elements of the array:\n"; PrintArrayOdds(list, 15); cout << "\nPrint the even elements of the array:\n"; PrintArrayEvens(list, 15); cout << "\nPrint the elements of the array divisible by 3:\n"; PrintArrayDivis3(list, 15); cout << '\n'; } void PrintArray(const int* array, unsigned int size) { bool first = true; cout << "{"; for (unsigned int i = 0; i < size; i++) { if (!first) cout << ", "; cout << array[i]; first = false; } cout << "}\n"; } void PrintArrayPositives(const int* array, unsigned int size) { bool first = true; cout << "{"; for (unsigned int i = 0; i < size; i++) { if (array[i] > 0) // IF the value is positive { // then print it if (!first) cout << ", "; cout << array[i]; first = false; } } cout << "}\n"; } void PrintArrayNegatives(const int* array, unsigned int size) { bool first = true; cout << "{"; for (unsigned int i = 0; i < size; i++) { if (array[i] < 0) // IF the value is negative { // then print it if (!first) cout << ", "; cout << array[i]; first = false; } } cout << "}\n"; } void PrintArrayOdds(const int* array, unsigned int size) { bool first = true; cout << "{"; for (unsigned int i = 0; i < size; i++) { if (array[i] %2 != 0) // IF the value is odd { // then print it if (!first) cout << ", "; cout << array[i]; first = false; } } cout << "}\n"; } void PrintArrayEvens(const int* array, unsigned int size) { bool first = true; cout << "{"; for (unsigned int i = 0; i < size; i++) { if (array[i] % 2 == 0) // IF the value is even { // then print it if (!first) cout << ", "; cout << array[i]; first = false; } } cout << "}\n"; } void PrintArrayDivis3(const int* array, unsigned int size) { bool first = true; cout << "{"; for (unsigned int i = 0; i < size; i++) { if (array[i] % 3 == 0) // IF the value is divisible by 3 { // then print it if (!first) cout << ", "; cout << array[i]; first = false; } } cout << "}\n"; }