When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
174 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
rip
!homework
Welcome to Together C&C++! We won't do your homework for you, but we are happy to help you learn and point you in the right direction. We can help most if you have a specific question / have started writing the code.
(Please refer to our #rules, 5.)
@dense anvil Im not asking for someone to do my homework lol
litterally read the title
maybe I can discuss this problem with someone
aka where do i start
try breaking the problem into a smaller piece? Could you do it in just one dimension if it was an array instead of a matrix?
chetco!!!!!!!!!!
my 2x hero
hi again
uhhh yes I think so
thats a good idea maybe I can do it in peices
i just did the assignment so its really not that hard
i promise, it just looks like a lot
wait it took u 9 minutes?
its only about 30 lines of code including printing the result so trust me you got this
haha no take your time, just because I have dozen years experience in C
... mostly because its the night before halloween and I am alone with no-one doing CSC and math
...troll despair
try one dimension. I wil lgive you a hint if you like (use modulus operator)
ohhh
L = [6, 10, 17]
s = ""
for i in range(2):
s += str(L["""??? what goes here???"""]) + " "
print(s[:-1])
one dimension example
what on earth is that
in python
oh
ok
ima work in the middle now
wait
what
no what I did made no sense
deleted it all
Actually maybe I don't know how to do it in one dimention
the hardest thing im having
is have the same row repeat multiple times
its similar to repeating the same elements multiple times in 1 dimension
its all about how you index the 2d array
imagine you have array like
double A[5] = {-4, 5, 3, 9, -2};
A[2] would give you 3
right
A[6] is out of bounds
true
in comes modulus operator
the expression x % 5 will always give you a result less than 5
so you are never out of bounds
and A[6 % 5] simplifies to A[1]
coudlent u just loop through
each element of the array
and be like while its less than 5
evaluate expression A[x % 5] for x between 0 to 10
and you wil see a repetition
it gives all elements of A then starts back at the beginning when x is out of bounds of A
and you could keep looping x as long as you want really
i assumed first dimension is 'rows' of the matrix
you have n rows I believe, so you are on the right track but you did not use A yet
oops hahaha
but your online submission thing might prefer a different thing idk
eh does not matter
prof does not look at the code i could use litterally anything
a computer checks it
if you use wrong index your matrix will be transposed in memory
and computer will say wrong answer
looking better but might be wrong still idk. if s is rows of B then what is correct between these two options:
B[row][column]
B[column][row]
lemme pull up expected output
n and s are rows,
k and t are columns
and
but if i write B[x] what did I index into, the row or column?
then your code B[0][i] = A[0][i%n]; is using i to index the column?
wait a second
actually reading your assignment comments they say "if A is a 2 x 3 matrix" and then it shows 2 rows 3 columns
so yeah now it looks correct your last change
when I am stuck I like to take a guess
good guess
ok
so since its rows
by collomns
my nested loop will be looping le columns
so then I do the same trick
that you did
sounds good
modulo hack
but colomns
wait a second
hmmm
wait a secondo
i dont know if this will work
cus im just
indexing [0] of the row and columns
ok but you are close except
B[i][0] = A[i%n][0]; should be a red flag because we don't assign arrays to other arrays
which feels like what u intended?
you can do the whole function in like 3 lines of code not counting declarations and braces
hmm
sneaky delete for u just a hint
I don't know whats wrong with mine tho
I know its wrong
I think I have to assign B to A there
in order to update the columns
idk is it wrong? I feel like it is but I don't actually know lol
it is wrong
you are assigning only one element in that line of code each time you loop through i
so you should expect it to be wrong because you make a total of i + j assignments for a s x t matrix
or s + t assignments i think?
also you overwrite your assignments i believe
how would I change it without overwring it
if i = 0 you overwrite B[0][0] and then move into the loop and with j = 0 you instantly overwrite B[0][0] yet again
ah right
at no point are you indexing the columns, only the rows, you are still in one dimension
only ever indexing column 0
now whenever you index the columns you only do so on row zero
maybe that should be
j
nvm it should not be j
*i was referencing B[j][j] = A[j][j%k] but that did not work
I really want to give you another hint but I am shoehorning you into the 'correct' answer only because its very simple solution and the one they probably want you to find
funny thing I believe last time I helped you that you found the solution before me, I think you will find this
i think
correct but you did not need the outer loop assignment only the inner part
lol
hoooooly
chetco
man
thank you
i might have time to take a shower and go outside tonight
!solved