+ 1

How can I satisfy all test cases in c++ transportation challange?

Here is my code #include <iostream> using namespace std; int main() { //your code goes here int empty_seat ; int people ; empty_seat=50-(people%50); cout<<"input number of passangers"<<endl; cin>>people ; cout<<empty_seat<<endl; return 0; }

28th Nov 2020, 6:42 AM
Mihretab Dawit
Mihretab Dawit - avatar
5 Answers
+ 3
Given the previous answers, it seems the question/ code has been edited before, but right now, there are two issues. First of all, your program is executed from top to bottom. That means you need to take the input and store it in a variable before operating on that variable. Don't operate on a variable that you haven't assigned a value. The correct sequence is cin >> people; ... empty_seat = 50 - ( people % 50 ); and not the other way around. Furthermore, when solving for automated test cases evaluated by a computer, it is absolutely important to match the required output format. Printing anything beside that, e.g. your first std::cout statement, is going to make the evaluation of your answer fail, even if the result was correct. AzhagesanăƒŸ(˙❄˙) You have a typo in your answer, you use std::cin with the >> operator, the << operator is associated with the output stream.
28th Nov 2020, 10:07 AM
Shadow
Shadow - avatar
+ 1
Share your attempt first. We don't have mind readers here.
28th Nov 2020, 6:48 AM
Artem đŸ‡ș🇩
Artem đŸ‡ș🇩 - avatar
+ 1
Mihretab Dawit you need to take an integer input and output the answer of that integer, you don't have to use any random number.
28th Nov 2020, 6:57 AM
XXX
XXX - avatar
+ 1
Declare a variable and use cin>>variable; Then pass that variable to your function transportation (variable)
28th Nov 2020, 7:07 AM
AzhagesanăƒŸ(✿)
AzhagesanăƒŸ(✿) - avatar
+ 1
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:45 PM
Lam Wei Li
Lam Wei Li - avatar