Help me please
How can i code this : ! # # # # # # # # # #@ # # # # # @ # # # # $ # @ # # # # @ # # If we have 4 @ One ! and one $ and the other are #, (so we have 26 #) ! Is always upest and leftest(like I have drawed) , and others are random. https://code.sololearn.com/cPUurhqR4ozg/?ref=app This is my try, it didn't work.
1/20/2022 7:29:32 AMhanie
24 AnswersNew Answer
hanie , this is solution for that based on an idea of random index of the board‘s array. Happy coding. https://code.sololearn.com/clFs8Bdx3W98/?ref=app
Thank you :) Well, that is an interesting approach. Without calculating the probability of it to fail, I would guess that chances are high that it will work. There is, however, a chance that it will not. I wonder if you can imagine, why. Here's why: there is no guarantee that your code will print one '$' and four '@'. So, my first thought would be how to make sure the code always does. I would make an array and fill it with '!' at position zero and '#' otherwise. Then do a random draw for one '$' and four random draws for '@'. It is easy to verify that a position in the array is not taken twice by this process by checking a[pos] == '#'. Then, you need to print it as desired. You don't have that in your code, yet.
Quoi Runtime that is awesome! Thanks a lot.
Yep. I would %100 benefit from reading all the instructions.... That is fixed, and I've corrected the 4*$ to be 4*@. I'm gunna try using pointers instead of char. Wish me luck!
Jonas your right. I added
Jonas thanks. Should I change it to multi array? I mean change it to arr (In the next step I should code sth that make i move by user)
That seems to make things unnecessarily complicated, in my opinion. It would also be possible to reshape the array later, but that is rather advanced C. I'd go with a one-dimensional array and indicate its shape on screen with parameters to a print function.
Oh wait, I just noticed the addition there. Hm, if a 8x4 array makes things easier later on, yes, that might be a good choice...
JaScript thanks alot ❤❤❤ you don't know how it means to me.
hanie You are welcome!
Quoi Runtime I got the answer thanks
Wer hat gefragt
Quoi Runtime I want the result be like a 4×8 matrix which the "!" Has a particular place and we have one of it, then we have 4 @ one $ and 26 # which they are in random places
G'day hanie I've also had a go at your project. My attempt is in C. https://code.sololearn.com/cxWVjyxA9Q33/?ref=app
HungryTradie that is so good, thanks. But only one problem. ! Should be upest and leftest
HungryTradie wish you the best🌝
With pointers https://code.sololearn.com/cRiyH5sl6Wkp/?ref=app It is very clunky, I had to use (*(grid+(i*COL)+j)) so many times to traverse the array 1 char at a time.
G'day Quoi Runtime this almost works..... https://code.sololearn.com/cPv8Yc2J3luG/?ref=app
That is unfortunately NOT how this forum works. You may ask for help on any specific problem you run in to while learning to code or attempting to write a program. However, this is not a code ordering service. If you have tried anything, then please present your work so we can assist you. Otherwise, put in some effort to at least TRY to solve the problem. It will only be to your benefit! Thank you.