+ 3

Transportation

Can someone help with the transportation code in C++ please?

16th Mar 2021, 2:01 PM
Mustafa Mansuor
Mustafa Mansuor - avatar
12 Respostas
0
Mustafa Mansour Just one line of code cout << 50 - passengers % 50; Where passengers is input.
16th Mar 2021, 3:00 PM
AÍąJ
AÍąJ - avatar
+ 6
Hi! what exactly was the problem? ask a specific question
16th Mar 2021, 2:07 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
Oh, so you can do it in few 3-4 lines😅 The one user variable you need is an amount of passengers. If we are talking about the same task, your bus can accommodate 50 passangers. So, your formula gonna be: 50 - passengers % 50 Where the "passengers" is total amount of passangers, and "50" is amount of passengers that can contain the bus in full
16th Mar 2021, 2:35 PM
Nazeekk
Nazeekk - avatar
+ 1
#include <iostream> using namespace std; int main() { //your code goes here int a=126; int b=50; int seats; int p1; int p2; seats=(a-b); p1=seats-b; p2=b%p1; cout<<"seats left empty :"<<p2<<endl; return 0; }
16th Mar 2021, 2:27 PM
Mustafa Mansuor
Mustafa Mansuor - avatar
+ 1
thank you guys! much appreciation
16th Mar 2021, 4:44 PM
Mustafa Mansuor
Mustafa Mansuor - avatar
0
Wdym about that? You want to take code from another language and remake it for c++?
16th Mar 2021, 2:06 PM
Nazeekk
Nazeekk - avatar
0
No, he wants to solve the problem of lessons with passengers on the bus
16th Mar 2021, 2:11 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Ouch 😅 Then, Mustafa Mansour , show us your attempts or describe what exactly didn't you understand
16th Mar 2021, 2:17 PM
Nazeekk
Nazeekk - avatar
0
thats what i did ( not really a good coder btw)
16th Mar 2021, 2:27 PM
Mustafa Mansuor
Mustafa Mansuor - avatar
0
i get the answer 24, which is supposed to be the right answer but it doesnt give me any indication that my answer is right
16th Mar 2021, 2:54 PM
Mustafa Mansuor
Mustafa Mansuor - avatar
0
I typed this code in transportation program in c++ but I am getting negative output instead of a positive one please clear me #include <iostream> using namespace std; int main() { int passenger; int available; int remseats; cin>>passenger; if(passenger<=50){ remseats=passenger-50; cout<<remseats; } else{ remseats=passenger-50; available=passenger-50; cout<<available; }; }
27th Apr 2021, 4:22 AM
amogus
0
Drunken Troll first, for your calculations, you need to discard, cross out, separate the total number of passengers that can be taken away by fully filled buses... remember, that one bus can accommodate 50 passengers
27th Apr 2021, 7:38 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar