+ 2
Hello everyone if anyone can help me break down this problem C++
Hello, I was wondering If I can get some help or some advice on how to program this functin so assume that I made a 4 by 4 array example : int a[4][4] = { { 1,4,5,6 }, { 2,12,11,3 }, { 8,16,23,32 }, {9,14,20,21} }; Assume that the value starts at [0][1] to [1][0] to [2][1] to [3][2] to [2][3] to [1][2] then to [0][1] the pattern is that each value is not going outside of their boundary and for the function, I want to add them all up so how can I start programming this.
19 ответов
+ 2
This will help you for handling with 2D arrays. For more information please link here your attempt:
https://code.sololearn.com/chi7HM5s0V90/?ref=app
+ 2
Think of a ping pong bouncing off starting from its origin point and bouncing off when it touches a wall then goes all the way to its origin, if you make a 4 by 4 and follow what the columns and rows youll see that it will form a parallel
+ 2
Okay, anyways thanks for help when you have the time you can explain it to me how to set it up as a for loo0
+ 2
. 0,1
1,0. 1,2
2,1 2,3
3,2
you can keep xstart=0, ystart=1 as initial coordinates, and then you can move in 4 directions sequentially and stop when starting coordinate is reached. To make it more simple you can make 4 loops one after other for each direction in same sequence like first going down-left then right-down then up-right etc, and break from each loop when same coordinate is reached or can't make a move.
Atmax 4 loops only because if you'll try with some NxN boards then it will reach same coordinate after 4 loops.
+ 2
boba yes you can that. Please se my updated code, how it can be done:
https://code.sololearn.com/chi7HM5s0V90/?ref=app
+ 2
Hey, I've written a function that traverses your 2d array with "bouncing on the walls" for a given first and second point. You can customize it for your own problem.
https://code.sololearn.com/c20BK8vTVl72/?ref=app
+ 2
boba only for an example to learn, now you can build your own patterns.
+ 1
JaScript like I want to start at 2 at the first column to 4 in the second column to 11 in the third to 32 in the fourth to 20 back to the third to 16 in the second and back to 2 in then first
+ 1
So technically theres a 4 by 4 array and i have a total of 6 values in this 4 by 4 one starting off as its first destination at [0] [1] then it adds another value to [1][0] then it adds to [2][1] then to [3][2] to [2][3] to [1][2] to [0][1] stops at [0][1] like its travelling
+ 1
Is it possible to do that off of a for loop? Martin Taylor
+ 1
Think of a ping pong bouncing off starting from its origin point and bouncing off when it touches a wall then goes all the way to its origin, if you make a 4 by 4 and follow what the columns and rows youll see that it will form a parallel
+ 1
boba yes you can that. Please se my updated code, how it can be done:
https://code.sololearn.com/chi7HM5s0V90/?ref=app
+ 1
Good job JaScript
+ 1
4 3?
0
Michał Doruch will you help.me.ouy
0
Martin Taylor any advice on how to do this, more like a traversal array problem I guess you can say
0
[Columns][Rows]
0
Why is it 4 3
0
??