Question
The objective is to use each row of the first column as a starting point to come up with a sum of absolute value of
The objective is to use each row of the first column as a starting point to come up with a sum of absolute value of differences . For each row, a sum will be calculated, therefore, 5 sums must be calculated. Each sum will be placed into the array, sumList[ ].
#include
for(r=0; r < ROWS; r++) printf("%8d %8d ",r, sumList[r]); //should display
return 0; } /* * Receives 2d matrix that represents topography * and uses this data to calculate an elevation path sum for each * row. * Input: topog[][] * Output: sum[] * */ void calcSums(int topog[ROWS][COLS], int sums[ROWS] ) { int i,j; for( i=0; i int sum= abs(topog[i][j])- abs(topog[i][j+1]); int sum2 = abs(topog[i+1][j])- abs(topog[i][j+1]); int sum3 = abs(topog[i-1][j])- abs(topog[i][j+1]); if (sum < sum2&& sum< sums3){ sums[i] = sum; } if (sum2 < sum1 && sum2< sums3){ sums[i] = sum; } if (sum3 < sum1&& sum3< sums2){ sums[i] = sum; } sums [i] = topog }} sums[i] = 99999; //place sums in this array. One sum per row }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started