EXERCISE 00): Prepare a Checkerboard Write a C program prep_checkerboard.c which scans in instructions from the user on

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

EXERCISE 00): Prepare a Checkerboard Write a C program prep_checkerboard.c which scans in instructions from the user on

Post by answerhappygod »

Exercise 00 Prepare A Checkerboard Write A C Program Prep Checkerboard C Which Scans In Instructions From The User On 1
Exercise 00 Prepare A Checkerboard Write A C Program Prep Checkerboard C Which Scans In Instructions From The User On 1 (163.67 KiB) Viewed 49 times
Please include your code screenshots, thank you
EXERCISE 00): Prepare a Checkerboard Write a C program prep_checkerboard.c which scans in instructions from the user on filling a 2D array representing a checkerboard. Download prep_checkerboard.c here, or copy it to your CSE account using the following command: $ cp −n /web/cs1511/22T2/activities/prep_checkerboard/prep_checkerboard.c . The goal of this exercise is to give you more experience manipulating 2D arrays of structs. In this exercise, the 2D array of structs is in the form of a grid, representing a checkerboard. The checkerboard will appear similar to: row --> column | \ | / | I | I | | | | | | | T | | I Your program must continuously take in 'instructions' on how to fill the checkerboard with pieces. Each instruction is a line containing 4 inputs separated by whitespace: 1. The first input is the row coordinate of the piece on your checkerboard. 2. The second input is the column coordinate of the piece on your checkerboard. 3. The third input is the color of the piece. This MUST be either 'R' (red) or 'B' (black). 4. The fourth and final input is the "type" of the piece. This can be a king (1) or not (0). A sample instruction would be: 0 1 R 0. This places a red piece ('R') on coordinate (0, 1) of the checkerboard, and the piece is NOT a king (0)
Your program must continuously take in 'instructions' on how to fill the checkerboard with pieces. Each instruction is a line containing 4 inputs separated by whitespace: 1. The first input is the row coordinate of the piece on your checkerboard. 2. The second input is the column coordinate of the piece on your checkerboard. 3. The third input is the color of the piece. This MUST be either 'R' (red) or 'B' (black). 4. The fourth and final input is the "type" of the piece. This can be a king (1) or not (0). A sample instruction would be: 01 R. This places a red piece ('R') on coordinate (0, 1) of the checkerboard, and the piece is NOT a king (0). Note: You do NOT need to write or edit the print_checkerboard() function; this has been provided in the starter code and only prints a visual representation of the checkerboard in the terminal. You may want to understand how it works for more information, but your program should only conclude with calling the print_checkerboard () function on your checkerboard 2D array. Your program must follow these examples exactly: $ ./prep_checkerboard Please enter pieces: 0 0 RO 0 1 R 0 02 R0 03R0 0 4 R0 05 R0 06 R0 0 7 R 1 7 0 B 0 7 1 B 0 72 B0 73 B0 74 B 0 7 5 B 1 7 6 B 0 7 7 B 0 Ctrl-D | R | R | | R | 1 R R R | I R | R-K | |
Write a C program prep_checkerboard.c which scans in instructions from the user on filling a 2D array representing a checkerboard. Download prep_checkerboard.c here, or copy it to your CSE account using the following command: $ cp −n /web/cs1511/22T2/activities/prep_checkerboard/prep_checkerboard.c. The goal of this exercise is to give you more experience manipulating 2D arrays of structs. In this exercise, the 2D array of structs is in the form of a grid, representing a checkerboard. The checkerboard will appear similar to: column I \// + row --> | I T | I I I | | 1 I | I | | | | I | Your program must continuously take in 'instructions' on how to fill the checkerboard with pieces. Each instruction is a line containing 4 inputs separated by whitespace: 1. The first input is the row coordinate of the piece on your checkerboard. 2. The second input is the column coordinate of the piece on your checkerboard. 3. The third input is the color of the piece. This MUST be either 'R' (red) or 'B' (black). 4. The fourth and final input is the "type" of the piece. This can be a king (1) or not (0). A sample instruction would be: 01 R0. This places a red piece ('R') on coordinate (0, 1) of the checkerboard, and the piece is NOT a king (0). Note: You do NOT need to write or edit the print_checkerboard () function; this has been provided in the starter code and only prints a visual representation of the checkerboard in the terminal. You may want to understand how it works for more information, but your program should only conclude with calling the print_checkerboard() function on your checkerboard 2D array.
Your program must follow these examples exactly: $ ./prep_checkerboard Please enter pieces: 00 RO 0 1 R 0 02R0 03R0 04 R0 05 R0 06R0 0 7 R 1 70B0 7 1 B 0 72 B0 73 B0 74 B 0 7 5 B 1 76 B 0 7 7 B 0 Ctrl-D +-- | | | | | | | +- R I | + B R I B | | B I R 1 B | | | B I R | R | R-K | | B-K | -+-· | B | B | -+ —+——-
$ ./prep_checkerboard Please enter pieces: 00R0 7 6 R 1 4 4 B 0 07 R0 2 3 B 1 4 6 B 0 5 1 R 0 7 0 B 0 Ctrl-D | | | I I + R B | B-K | B B | R-K | Assumptions/Restrictions/Hints • You can assume that the row, column, piece color and type provided is always valid. • You can assume that the piece color provided is always in uppercase. • You can assume that pieces on a square will never be replaced with another color. • There is no set number of instructions. You must continuously take in instructions until Ctrl+D is entered.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply