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 <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ROWS 5
#define COLS 6
void calcSums(int topog[ROWS][COLS], int sumList[ROWS] );
int main()
{
int topography[ROWS][COLS] =
{
{ 3011, 2800, 2852, 2808, 2791, 2818 },
{ 2972, 2937, 2886, 2860, 2830, 2748 },
{ 2937, 2959, 2913, 2864, 2791, 2742 },
{ 2999, 2888, 2986, 2910, 2821, 2754 },
{ 2909, 3816, 2893, 2997, 2962, 2798 }
};
int sumList[ROWS] = {0};
int r,c;
/* student to implement calcSums */
calcSums(topography, sumList ); //pass in topography, get back list
of elevation sums
for(r=0; r < ROWS; r++)
printf("%8d %8d \n",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<ROWS; i++){
for (j= 0; j< COLS; j++){
//placeholder. Calculate correct sums
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
}
If you have any doubts, please give me comment...
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ROWS 5
#define COLS 6
void calcSums(int topog[ROWS][COLS], int sumList[ROWS]);
int main()
{
int topography[ROWS][COLS] = {{3011, 2800, 2852, 2808, 2791, 2818},
{2972, 2937, 2886, 2860, 2830, 2748},
{2937, 2959, 2913, 2864, 2791, 2742},
{2999, 2888, 2986, 2910, 2821, 2754},
{2909, 3816, 2893, 2997, 2962, 2798}};
int sumList[ROWS] = {0};
int r, c;
/* student to implement calcSums */
calcSums(topography,
sumList); // pass in topography, get back list of elevation sums
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 < ROWS; i++)
{
sums[i] = 0;
for (j = 1; j < COLS; j++)
sums[i] += abs(topog[i][j] - topog[i][j - 1]);
}
}

The objective is to use each row of the first column as a starting point to...
Please do in C please. Edit sliding.c. Comments
on code would be nice. Thank you.
Here is main.c
#include "sliding.h"
#include <malloc.h>
#include <stdlib.h>
//Prints grid in row major order. Tries to ensure even spacing.
void print_grid(int * my_array, int rows, int cols){
int i,j;
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if(my_array[i*cols + j]!=-1){
printf(" %d ", my_array[i*cols + j]);
}
else{
printf("%d ", my_array[i*cols + j]);
}
}
printf("\n");
}
}
int main(int argc, char *argv[])
{
int seed,rows,cols;...
I have a question about C++. I have to code the 8 queens puzzle without using any recursive methods. Every time the program runs, it will randomly place 8 queens throughout the board. I got that working, but the issue is the board is suppose to be filled with asterisks and the queens are suppose to be represented with a Q. I have put zeros instead of asterisks and ones instead of Qs, i tried to fix it but it...
I'm having trouble correctly sorting my 2d array/matrix. I need it so its row-wise sorted (meaning the values in the rows go from low to high). I tried to make the sort function but it just puts all the numbers from lowest to highest, up to down in column format. So please please help me fix it so it sorts correctly, I have bolded the code that needs to be fixed, everything else is fine. The code is below: #include...
Sometimes when I sit in restaurants waiting on food, I request the children’s menu to play the games. One of my favorites is the word puzzle in which you search for words hidden in a scramble of letters. I began to work out a solution to this game programmatically. That seemed a little simple, so I decided to have you solve the problem of a scramble of integers, finding the sub-row or sub-column which sums to another integer. You will...
Concepts tested by the program:
Working with one dimensional parallel arrays
Use of functions
Use of loops and conditional statements
Description
The Lo Shu Magic Square is a grid with 3 rows and 3 columns
shown below.
The Lo Shu Magic Square has the following properties:
The grid contains the numbers 1 – 9 exactly
The sum of each row, each column and each diagonal all add up
to the same number.
s is shown below:
Write a program that...
Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...
Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...
I was asked this question:Given any input series a corresponding graph must be generated without the use of any libraries.After, trying my best, I arrived at this solution to which they replied it had a logical issue.# Create the matrix print("Enter the sequence with spaces: ") arr = list(map(int, input().split())) count = len(arr) rows = int(sum(arr)) cols = int(sum(arr) + 4) content = [[" "]*cols for _ in range(rows)] maxq = 0 maxp = 0 content[0][0] = "/" # Apply the positions in the matrix p = 0 q = arr[0] k = 0 for l in range(q): if (k != q): content[k][p] = "/" p = p + 1 k = k + 1 p = q flag = 1 i = 0 j = 0 k = 0 c = 0 temp = 0 r = 0 flag = 1 for i,j in enumerate(arr): c = c + 1 if c < count: k = arr[i+1] else: k = 0 if arr[i]: if flag == 1: content[q][p] = "/\\" if maxq < q: maxq = q maxp = p qori = q pori = p p = p + k temp = q - k...
The second problem, the one I'm asking about, is only making
changes to the first problem, which I have included the correct
code for. Thank you!!
een be modeled by diding the plate io adiscrese grid of cels and sulting the change in tenspentureof ell over 90 2.2 3) dared es dlebel css (saggestion:use5 both ves w fint, ut increme this 1o 20asee you get yeur pragranı warking. Your progrars shcald do the Sllasing lain the cs alus of the...
photos for each question are all in a row
(1 point) In the following questions, use the normal distribution to find a confidence interval for a difference in proportions pu - P2 given the relevant sample results. Give the best point estimate for p. - P2, the margin of error, and the confidence interval. Assume the results come from random samples. Give your answers to 4 decimal places. 300. Use 1. A 80% interval for pı - P2 given that...