- 1

[QUESTION] Transportation project

Hi all ! I have a little question about the transportation project in SoloLearn. I'm supposed to find the output 24 and use the input 126. I used the following code : int total = 126; int a = total % 50; int b = 50 - a; cout << b; Thus I obtain the output 24 but the programs says it's wrong. I've seen somewhere the good answer is : int total; cin >> total; ... The answer is the same (24) but now it says the answer is right ! And I can't understand why you have to use the cin expression to make it right. Could someone explain it to me ? Thanks people !

25th Nov 2020, 7:31 PM
Julien Allard
Julien Allard - avatar
5 Réponses
+ 4
A simple three lines of code implementation. First, you use the modulus function to find the remainder, which are the passengers on the last bus. Then, to find the empty seats, you use bus capacity minus away the last passengers. https://code.sololearn.com/cAsIKRZH3quK/?ref=app
16th Dec 2020, 12:39 PM
Lam Wei Li
Lam Wei Li - avatar
+ 1
Oh ok, I just understood thanks to you. I didn't understand at first that we had to ask for user input (since they already give you the total number of passengers as input). It wasn't clear at all to me. So it wasn't about the result but about the steps to go there. Thank you !
25th Nov 2020, 7:42 PM
Julien Allard
Julien Allard - avatar
0
This really helped out, it appears that I was looking at the program from a completely incorrect perspective.
19th Feb 2021, 7:18 AM
Ivan Hart
Ivan Hart - avatar