wow !!!!
Finally it worked coder777 , could you please explain me why previous solutions were not working and this solution worked ??? what mistake we were making previously ???
I am still not sure why you added this line that makes it run correctly if (borrowed[j]>borrowed[i]) borrowed[j]--; // the right books
And thanks a lot coder777 , i know you had worked a lot on this , really lot on this , and finally got it finished . Hats off to your efforts and committment , or else i had literally given off the hopes , and i believe you would continue extending your help like this .
The point of that line is that the user input index is corrected so that it is correct for the next user.
if the first user takes the first book, for the next user the first book is the previously second one. So that line makes second (and all following in the borrowed array) book to the first book for the next user.
And thanks a lot coder777 , i know you had worked a lot on this , really lot on this , and finally got it finished .
not that much. Sure I had to write it done and test it that took some minutes. The explanation took me some more time
i had literally given off the hopes
If you have no idea what's wrong with your code then plaster it with output. If you found the place where it goes wrong tweak it as long as it doesn't do what you want. You learn a lot from this.
and i believe you would continue extending your help like this .