Hello.
I have a few questions for everyone. We have a large programming assignment we are working on. We have to make a program which arranges rectangles on a giant x,y grid (a bigger rectangle). We have an objects.dat which looks like this:
400 200
20 30 5
10 40 3
25 30 4
The top 2 lines are the width and heighth of our giant rectangle (the "grid"). So first we wrote a code to read in these 2 lines and turn the numbers into variables. We can't figure out how to setup a variable-length array to where the array size is of our variable lengths. We are setting up a large array to pretend it's our grid...so it's size will be the size of the top line in the program.
The lines besides the top line are the smaller rectangles that are supposed to fit. The first number is the width, the next numbers it the heighth, and the final number is how many objects of that size there are. Our program is supposed to arrange each rectangle in an order symmetrical to the center of the grid. The lower left point on the grid is 0,0...the x axis increases with it goes right, and the y axis increases when it goes up.
We would like someone to explain to us how to make an array of variable size...and if anyone has any better ideas of how to arrange rectangles to make them fit, please let us know.
PLEASE HELP US!