add lab3 solution

This commit is contained in:
2025-02-12 12:09:42 -05:00
parent b469d0a85d
commit edb1a007c0
2 changed files with 13 additions and 8 deletions

View File

@@ -44,10 +44,10 @@ void identifyMeanAndMin(const std::string& filename) {
float* avg;
/** PART 1: ADD CODE BELOW **/
numElements = new int;
sum = new int;
smallestNum = new int;
avg = new float;
/** PART 1: ADD CODE ABOVE **/
*numElements = 0;
@@ -66,10 +66,11 @@ void identifyMeanAndMin(const std::string& filename) {
/** PART 2: MODIFY CODE BELOW **/
for (int i = MAX_ARRAY_SIZE; i >= -1; i--) {
for (int i = *numElements - 1; i >= 0; i--) {
// If we're at the beginning of the for loop, initalize *smallestNum
// Else, compare *smallestNum to current element in the for loop
if (i == MAX_ARRAY_SIZE) {
if (i == *numElements - 1) {
*smallestNum = *(intArray + i);
}
@@ -98,7 +99,11 @@ void identifyMeanAndMin(const std::string& filename) {
/** PART 3: ADD AND/OR MODIFY CODE BELOW **/
delete intArray;
delete[] intArray;
delete numElements;
delete sum;
delete avg;
delete smallestNum;
/** PART 3: ADD AND/OR MODIFY CODE ABOVE **/
}