0
Hell me out here pals I am unable to write this code C++.
You are making a program for a bus service. A bus can transport 50 passengers at once. Given the number of passengers waiting in the bus station as input, you need to calculate and output how many empty seats the last bus will have. Sample Input: 126 Sample Output: 24 Explanation: The first bus will transport 50 passengers, leaving 126-50=76 in the station. The next one will leave 26 in the station, thus, the last bus will take all of the 26 passengers, having 50-26=24 seats left empty.
6 Respostas
+ 1
Martin Taylor is right. Problem can be solved in single line:
int result = (50 - num_of_passengers % 50)% 50;
+ 1
Martin Taylor thats why I added % 50 at the end of expression.
0
Use search bar please, there are a lot of questions about this, at least a few every week
0
Ok
0
Thank you
- 1
Just use while loop for transportation of buses...
it's easy try to implement first if you stuck then ask your problem here... don't just ask for others codes..
by seeing others code build your own logic...
happy coding! 😉
https://code.sololearn.com/cFtuhlCwucwF/?ref=app