The user can do Insert, Append on the row they are in, The user can reverse, delete repeated numbers, sort the current row in ascending or descending order. The user can delete the cell they are on, The user can search the entire array for an item and have the cursor rest on that item. The user can choose to generate random numbers for the array: For each row, generate a RANDOM NUMBER OF RANDOM NUMBERS: Example: row0: 4 random numbers, row1: 6 random numbers row2: 6 random numbers. Be careful not to overflow the arrays.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

PLEASE CODE THIS IN C++ LANGUAGE.

Design the Two Dimensional Navigation Array.

The user will use the number pad keys or keyboard keys 4/s (left), 6/f (right), 8/e (up), 2/c (down) 7(home: 0:0) and 1(end: last:last) to move around the array. Implementing diagonal keys would be pretty cool too but not a requirement.
The user can do Insert, Append on the row they are in,
The user can reverse, delete repeated numbers, sort the current row in ascending or descending order.
The user can delete the cell they are on,
The user can search the entire array for an item and have the cursor rest on that item.
The user can choose to generate random numbers for the array:
For each row, generate a RANDOM NUMBER OF RANDOM NUMBERS:
Example: row0: 4 random numbers, row1: 6 random numbers row2: 6 random numbers. Be careful not to overflow the arrays.
My Solution:

main() function:

declares major variables: the 2D array etc.
Contains a loop that takes commands and calls appropriate functions: Cursor movements, Insert, Append, Delete, Random, etc.
Call print on every iteration of the loop
The number of interesting elements in rows of the 2D array:

are kept in an array of ints.
I pass sizes[row] to the Append, Insert and Delete functions passed by reference. sizes[row] means how many numbers in each row are saved into an int array.
cursor

is implemented using two integers. Let's call them row and col
The MoveCursor (up, down, left, and right) functions
Move the cursor by incrementing and decrementing row and col
And they make sure:
row and col stay within the range 0..MaxRows and 0..#used in the current row.
If there are no elements in that row, I set the col to -1 (this flags the deal with the cursor on an empty row)
My Print function:

call the 1D print function for every row.
If the cursor is not on a given row, just pass position -1 to the 1D print function. This will cause our old Print function not to display a cursor.
If the cursor is on a given row, well.. this is simple, just tell it where to display the brackets.
if the row you are printing has no "interesting elements" AND the cursor is on this row (it will have a col of -1) just print a "[:]" at the start of the line.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education