❔ Working w/ 2D Arrays
Hey all, new to the server and programming in general. Working on an assignment going over 2D Arrays. I'm currently trying to get the user's row and column input, find the specified index in the array, and print the new modified array, how should I go about doing this?
9 Replies
Where are you having problems? In traversing the 2d array?
Here's something you should definitely try,
create functions to do the small things that your code does.
Like a function to take user inputs,
another function to traverse the array,
another function to modify an item inside the array.
BlazeBin - nahnddtmyidt
A tool for sharing your source code with the world!
While writing these functions, you yourself will get an understanding of what parameters these function should take and what values should these functions return.
This approach will help you organize your code more better and make things cleaner
Ah ok then.
It's sort of called "Separation of concerns"
i.e. you're separating .... concerns ... in separate code blocks
Another problem I've had (I had deleted the code before asking this question), was properly formatting the 2D array when I print it out.
Especially when the values themselves are greater than column/row #
A separate function to properly format the array
see where I'm going with this you create functions to do separate stuff
you can focus on main logic first, and work on formatting like things later
Basically divide the entire problem in smaller chunks
and try creating a separate function for each of those smaller chunks
ok
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.