Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 7 Background: We have a 10x10 virtual grid over the top of our park. 0,0 is in the top left and 9,9 is in

Lab 7

  • Background: We have a 10x10 virtual grid over the top of our park. 0,0 is in the top left and 9,9 is in the bottom right as youd expect. Every so often, our drone flies a random path over some of the grid squares. It counts the number of people in that section and records X, Y, P where X & Y is the grid coordinate and P is the number of people that are there.
  • Goal: The drone logs are written to a text file. Your job is to process this file and determine overall visitor patterns for the park.
  • Input: filename should be supplied as a command line argument
  • Output: Display the following information
  • Highest number of visits
  • How many locations have not been visited at all (just the count, not the list)
  • 10x10 grid of following values, no extra spaces or anything
  • H: If visits is over 10
  • L: if visits is not 0 (but not H)
  • .: if visits is 0

Use the following code segment to finish the code.

#include #include

// read the data from the file into the array void readData( int nums[][10], char fname[] ) { FILE *fp; int x, y, p; // x is row, y is column, p is number of people

// check if file can be opened

// use the loop below to read the data

// read first line while ( !feof(fp) ) { // update the array // read the next line } }

// print out the grid // . for no visit // L or H or low or high density void showVisits( int nums[][10] ) { // print it out

// also report // how many spots had no visits // what what the highest number of visits

}

int main( int argc, char *argv[] ) { int grid[10][10] = {0};

// make sure a command line argument was provided

readData( grid, argv[1] ); showVisits( grid );

return 0; }

Please help me finish this code. In c programming.

image text in transcribed

image text in transcribed

Sample input: I 14 235 1 1 15 4 0 0 1 8 9 19 9 9 1 * gcc park.c * /a.out visit . ..L... ...L... .......... No visits: 94 Max visits: 19

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Define defective goods. What are rework costs?

Answered: 1 week ago