Anyone know c++?

Im tryna understand this shit but i dont get it.

Theres matrix A, theres matrix B. I need to create matrix C which combines A and B. I get how thats done. But theres a problem as you can see in oic related. The last row is fucked and i cant fucking figure out why.

Attached: 7A1DAFA8-DB65-4F05-9F87-1DC5171C7BC9.jpg (1080x1920, 238.17K)

Other urls found in this thread:

php.net/manual/en/function.array-merge.php
twitter.com/SFWRedditImages

changing C[i][j]=B[i][j] to C[i][j]=B[i][j-n] fixes it. The problem is that i dont fucking know why, it literally makes no fucking sense

Attached: 6CE3DB79-CEEC-48A7-83D4-D5B6E097218E.jpg (720x1280, 237.54K)

No, I am not helping you

Attached: 1645845038740.jpg (321x360, 12.45K)

php.net/manual/en/function.array-merge.php

>khan academy
>epic games
>legacy windows
>edge
>steam
>two copies of blender
You must be at least 18 to post. Tell your mom to buy you a new PC too

You recognized all of those you faggot
Okay that doesnt answer my question. Im not trying to find a better way im trying to do this shit for school

>You recognized all of those you faggot
doesn't mean he uses all of them

>you know what annoying skiddies like me do and say and use, gotcha
Pretty easy when you post retarded shit like this constantly.

>if(iif(jIF (J

Attached: 1645047720982.jpg (385x390, 29.96K)

looking at line 36. assume
i is 2
j is 5
what is B[i][j]?

and what is B[i][j-n] (given n is 4)

lol thats funny user but its actually a lowercase L.
The thing our teacher made us do was to combine matrix A with B to form matrix C.
Basically what the program does is ask if the number youre about to place is in the first half (j

And no i and j start at 0 and they repeat until they reach n+l and m respectively

Why would you use C arrays if you are learning C++? Also, why would you write do?

i understand, but look closely at your B matrix and it's dimensions, and compare them what your actually trying to access.

look at lines 42 and 46. how high can i and j go? can you B matrix support that?

You haven't answered his question. B[i][j] is B[2][5], and B is a 4x4 matrix, accessing 5th element of it is erroneous.

Also fuck this is difficult to read. Have you heard about for loops?

Bro i have no prior coding experience other than c++ we started on it. Do while is a command (or whatever its called)
do
{
a
}
while(c) (c=condition)
Its just another form of for(i=0;i

That's fine, learning C parts of C++ first is a good approach. You should have used for instead of do while though.

Im confused why b would be 2,5? i and j only go up to m and n respectively. Every loop the j goes only to 3 (which is the 4th element since j=0 counts as one) and then it repeats with i=1, the j going up to 3 again, then with i=2 etc etc.

Do While is another form of a for loop

And as for why this is happening, my best guess is B is located before A in memory, so when you go out of bounds for B, you get values from A.

>Every loop the j goes only to 3
cum on m8 why do I know your code better than you? j goes to n+l-1 which is 7.

ā€œiā€ can go up to m-1 which is 3. That means it repeats for i=0 up to i=3 so thats 4 elements.

>i and j only go up to m and n respectively
interesting. so looking at this
while ( j

+ screen pic instead screenshot

Shit sorry i see my problem but why did that work in the first place without the j-n? in the first 3 rows it works correctly and it displays 4 in the second half even though j=4 which is out of bounds for B. Anyway thanks a lot for the help, i see i was just being retarded.

>why did that work in the first place without the j-n?
c++ does not care how retarded you are. if you want to shoot yourself in the foot, it will set you up to take your legs with it and even help you pull the trigger as long as it compiles. and if it doesn't compile all you get is autistic screeching

Sorry i know its confusing, i changed some stuff on the second pic as well. n is the first half of the matrix C it has a value of 4, l is the second half also value of 4. n+l is 8 which is the amount of columns the matrix has. I do n+l-1 because i start j at 0, and that counts so even though j goes up to 7, the amount of times a character was printed in a row was 8 because it includes the time J was 0.

Ive found the problem and solved my confusion though.

B is contiguous in memory in your case. Accessing B[0][4] (which is out of bounds) is same as accessing B[1][0]. So in effect while being out of bounds for row access, you were actually getting the right row numbers, just off by 1 for the column numbers. Change values in your matrices from all fives/fours to something identifiable (ie A from 1 to 16 and B from 101 to 116) and you can confirm it.

Swap rows and columns in my post, I got a bit confused there myself.

Ooooohhhhh that makes a lot of fucking sense. On the last loop, on the second half it was b[3][4] which made it b[4][0] which just doesnt exist. Im guessing that made it print A?