creating a grod | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

creating a grod

Hi. I want to try storing a representation of a grid and displaying it on screen.Program should read a grid, store it in a 2D data structure and then output it on screen. BLACK cells represented by 1 WHITE cell represented by 0. INPUT : first line of input consists of two integers (r) and (c) separated by a single space. These are number of rows and columns of the grid. (r) rows of input follows , each containing c characters separated by single space, which specify the colour of the call at that position. OUTPUT : output representation of a board l, using 1 for black and 0 for white cells. There should be no spaces between cells. E.g. Sample input of a user: 5 5 //first line for (r) and (c) 0 0 0 0 0 1 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 Sample output: 00000 10010 11100 00000 00000 without spacing. Please help if possible.

27th May 2022, 1:50 AM
Siyabonga Mbendane
Siyabonga Mbendane - avatar
1 Resposta
+ 1
You need to use 2D dynamic vector and then 2 nested for loops 2 times, once for reading and once for displaying. https://code.sololearn.com/c5iY4BigHGMK/?ref=app
27th May 2022, 5:14 AM
Vinit Sonawane
Vinit Sonawane - avatar