+ 1
☹️ code for me
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.
11 Answers
+ 7
No, we can't just give you the solution as we believe it will prevent you from learning. Try to solve it, review your lessons.
Please show us first your attempt, or if you have one, please share it so we may help. Thanks.
Here are hints:
https://www.sololearn.com/Discuss/2655123/?ref=app
+ 7
#include <iostream>
using namespace std;
int main() {
int a;int b;int c;int d;int e; cin>>a;b=50;c=a%b;d=c%b;e=b-d%b;cout<<e;
return 0;
}
this is the right decision
+ 2
Mubarak Hussain
As I said in my hints, LAST BUS is the priority.
For example:
126 passengers
50 capacity
So it means every bus, the maximum capacity is 50 (and in the problem, this is constant).
Now let's try to divide this 126 people to different buses with maximum capacity
Bus #1 --> 50
Bus #2 --> 50
Bus #3 --> 26
Total --> 126
Here the LAST BUS did not reached the maximum capacity of 50, which means that this bus has free seats, to solve for the remaining seats in the bus:
50 - 26
But how will we get this 26 or the number of the passengers in the last bus?
We may use the modulus operator ( % )
126 % 50 == 26
- - - - - - - - - - - - - - -
int a, b=50, last;
cin >> a;
last = a % 50
cout << 50 - last << endl;
0
《 Nicko12 》 sure. I tried it all the day.. i never asked for help ever. But today ☹️
0
Mubarak Hussain Good effort. Can you show us your attempt so far so we may help? thanks.
0
《 Nicko12 》
My attempts have no logic. But instead of laughing at me, please encourage me. I used if and else state as on prediction. And i was nice for the test #1, but not for #2 #3 and so on.
0
I think, I'm not so smart. Its second day of trying. 😭😭😭
0
#include <iostream>
using namespace std;
int main() {
int a, b=50;
cin>>a;
if(a>b){cout<<a-b<<endl;}
else {cout<<b-a<<endl;}
return 0;
}《 Nicko12 》
0
《 Nicko12 》 i did it before. It sent it to you in dm.
0
《 Nicko12 》 i did this too. I tried it for one hour. 😂
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for(int a=0;a<n;n--)
{if(n%5){cout<<""<<endl;
cout<<n<<endl;}
else {cout<<n<<"\nBeep";}}
return 0;
}