CS1575 Homework #1- Going Fishing Solved

35.00 $

Description

Rate this product

HOMEWORK #1:

Going Fishing:

For this assignment, you will submit a single C++ file called ‘fishbomb.cpp’. Remember to put your name and section at the top of your program file.
Your program should expect all input to come from keyboard ‘cin’, and all your output should be to the screen ‘cout’.

Problem:

Good News!! The Planet Express crew are going fishing! and Bender is doing so the way robots are meant to do it: with dynamite!. Using sophisticated robot technology, Bender is scanning the surrounding area with a sonar device. The sonar’s data represents the area around Bender as a grid, with the number of fish in each cell of the grid.

Ahhh… the joys of fishing

Help Bender figure out where to throw his dynamite stick to catch the maximum number of fish. Bender has only one dynamite stick and it explodes in a peculiar way: It blows horizontally and vertically across the water ( think bomberman )

Input:

The first line of the input states the number of test cases T, then T test cases follow. Each test case consists of a data grid. A test case begins with the numbers H and W; the height and width of the sonar data grid. H rows of W data points follow, describing the number of fish detected by the sonar.

Output:

For each test case, output one line containing “#t: at (r, c) Bender catches f fish.”, where t is the test case number (starting from 0), (r, c) are the row,columns where throwing the dynamite stick maximizes the number of fish caught and f is the number of fish caught.

Implementation Requirements:

Given that you do not know beforehand how large a sonar data grid is, your program should dynamically allocate a 2D Array after the width and height of a grid is read. Make sure to de-allocate the 2D Array after you find the answer and before your program moves on to process the next grid.

Submission:

Submit your assignment by placing all code in this assignment’s git repository in the course’s GitLab server, [link] . ( You should have a repository setup sometime over the weekend ).

Your program will be evaluated and graded on the Computer Science department’s Linux machines so your program needs to be compatible with the current system, compilers and environment.

Sample:

Input

Output

3
58
10011001 01010101 02131200 03112313 00372210
66
412006
675913
346211
100313
010112
021430
7 12 262622412521 100313001011 021430010110 131200010110 031183830012 003720313011 000301101100

#0: at (3,3) Bender catches 26 fish. #1: at (1,5) Bender catches 43 fish. #2: at (0,3) Bender catches 55 fish.

  • CS1575-HW1-bkv8xy.zip