+ 3
Help! Time limit exceeded while generating random number.
Well, I used srand and time to seed the number of an array the server seems to run out of time. How can I fix it?
13 odpowiedzi
+ 4
Your continue skips the rest of the code and play never changes so infinite loop.
move your srand line out of the loop or you will always get the same dice roll.
+ 4
Unless your array is huge, your code has a bug. Either post a link to it so we can help or start looking for a loop that never exits.
+ 4
I'd move input into loop and add exit command to leave loop. Then, you could get multiple dice rolls.
+ 4
Run it at least three times.
1) Just hit submit without giving data.
2) Put a couple p lines no e.
p
p
3) Put a couple p's with e.
p
p
e
+ 4
Put the guessing part in a function called only if you played. If I don't play, your higher/lower/similar won't make sense because there isn't anything to compare against.
Instead of saying similar, use same or identical. Similar implies it can be a different value as long as it matches some pattern that the previous value met. For example, sum1%6 == sum%6 would be one method of doing similar.
+ 3
For playground enter:
p
p
p
e
at prompt to run. Default play to '?' before each read so if you run out of inputs you error and exit.
+ 3
+ 2
https://code.sololearn.com/coJX9k92O07H/?ref=app
+ 2
didn't exit the while loop
+ 2
Thanks a lot. Its working. Forgot about what continue does😂😂😅😅.
+ 1
Lol.. I just asked you that question😂😂
+ 1
@mr.john the game is complete wanna check it out?
Here is the link: https://code.sololearn.com/coJX9k92O07H/#c
Tell me what you think and i will try to fix it in the next update LOL!
Gonna post it soon.
0
Where is the code?