0
Transportation Problems Case 1 and 2
So I've done both of these problems, but everytime I completed one of them, it gave me an error. For example, if I do the first problem, it says that is correct, than I do the second and it says that the first one in wrong....What can I do to have both of them right? Please help me. Thanks to everyone who will help me.
7 odpowiedzi
+ 1
surely find the correct (generic) algorithm ;P
+ 1
oh, and don't expect for someone to give you the code without trying to doing by yourself first: we are not code providers, and if you do courses it's normally that you want to learn/practice ;)
however, feel free to request for more help :)
0
@visph I'v done both of them correctly, but when I do the second, it says that the first one is wrong. Can you help me?
0
maybe...
share your attempt(s), so I or others will be able to guide you ;)
0
@visph I know that it isn't a great program, but I tried to do my best, I want to improve myself everyday. I will listen to any advice. Anyway, thanks.
Case 1
#include <iostream>
using namespace std;
int main() {
//your code goes here
int a=12;//input
int b=26;
int c=a-b;//output
cout <<c;
return 0;
}
Case 2
#include <iostream>
using namespace std;
int main() {
//your code goes here
int a=231;//input
int b=50;// n of passengers
int c=a-b;
int d=c-b;
int e=d-b;
int f=e-b;
int g=b-f;//output
cout << g;
return 0;
}
0
at first you don't have to hardcode the input, but read it from user: if you read the lesson(s) again, you should have learned how to do input and output...
anyway, to save a few your time, 'cin' is used to get input (Console INput), and 'cout' to print somethingd to screen (Console OUTput) ^^
so, you store input in a previously declared 'int' variable, that you could use to compute the result to be outputed with the generic formula for your problem...
0
as alternative, you may use loop to compute the result but despite a few less efficiency, you will learn that in the next lessons module...