It suppose to work? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0
19th Mar 2018, 10:28 AM
Guy293
Guy293 - avatar
2 Antworten
+ 6
The guess number in your code has the value rand()%1, which will return 0 no matter what. So the guess loop is infinite and you get the Time Limit Exceeded Error. Thus, change guess' value to rand()%10, and it will work fine. Secondly, your loops should not run from 0 to 3, but just from 0 to 2, as pin[3] is an invalid index if the size of the array is 3. So change the loop conditions to x<3 from x<=3.
19th Mar 2018, 10:43 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 1
@Kinshuk Vasisht Thx it worked
19th Mar 2018, 10:50 AM
Guy293
Guy293 - avatar