+ 3
What's wrong in my code ??
code C++ bugs: There are 126 passengers which wanna take the Bus. One bus has 50 places. How much buses are needed and how much places will stay free ...??? include <iostream> using namespace std; int main() { //your code goes here int pass; int pl; int sum; cin >> pass; cin >> pl; sum = pass % pl; cout << "Free bus places: " << sum << endl; return 0; }
4 ответов
+ 3
Thank u so much guys🙏🙏
I have really not understood that code. 😂
That's like I am 🤷🏻♀️
+ 2
126%50 = 26 is filled seats. Then empty seats are 50-26=24
Between if it code coach task then output only what is asked. No more extra or less characters..
+ 2
#include <iostream>
using namespace std;
int main() {
//your code goes here
int passenger=0,seat=0;
cin>>passenger;
seat=50-(passenger%50);
cout<<seat;
return 0;
}
You should not to take free places as input, only takes passengers and reminder of the division of passengers by capacity of the bus(50) ,then subtract from capacity of the bus(50).
+ 1
K1auDIa we don't search for the remainder (which is the actual passengers in the last travel), but how much places will stay free (which is the capacity of the bus minus how much passengers left in that last trip)