+ 1

Why answer print two times in certain values....

This code print the answer two times when I give input as 39,50,52,65,74,75,78,91,98,100,104. But other values less than 108 gives perfect one time value.... . . . The first input is how much answer for different values you want to print.... Then put the values above.... . . . . The code print https://code.sololearn.com/cRVSOGHEn7UQ/?ref=app

7th Apr 2018, 1:17 PM
Akash papnai
Akash papnai - avatar
3 odpowiedzi
+ 1
Case 39: Your code prints in this condition: else if(seat[q]==3*i||seat[q]==i+14) i is running from 1 to 108. At i=13 (13*3=39) this is true, but also at i=25 (25+14=39) That's why it prints 2 times. You should debug your code if it doesn't do what you expect. In the sololearn playground you can do this by printing out debug messages at different points where the error could happen. In an ide you can use breakpoints for this.
7th Apr 2018, 3:41 PM
Alex
Alex - avatar
0
I tried to figure out what this code is even doing. Had to modify the formating for this. But what do these variables even mean? You need to explain what you are trying to do. Here is the formated code: https://code.sololearn.com/c2VpVIX6Zx14/?ref=app
7th Apr 2018, 3:09 PM
Alex
Alex - avatar