add lab3 solution
This commit is contained in:
@@ -20,6 +20,6 @@ double compute_slope(const Point &a, const Point &b) {
|
||||
double run_x = b.get_x() - a.get_x();
|
||||
double run_z = b.get_z() - a.get_z();
|
||||
double run = sqrt(run_x*run_x + run_z*run_z);
|
||||
//double answer = rise / run;
|
||||
double answer = rise / run;
|
||||
return rise / run;
|
||||
}
|
||||
|
||||
@@ -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 **/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user