+ 1
help with the first C ++ "transport" problem
#include <iostream> using namespace std; int main() { int a; int b=50; int c; int d; int e; cin>>a; if (a<b){ e=b-a; }else if (a>b){ c=a-b; d=c-b; e=b-d%b; }else{ e=0; } cout<<e<<endl; return 0; } why a test case is not right, what did I do wrong? (the test case is the third, the hidden one)
3 ответов
+ 7
Your code is giving wrong output if
50 < a < 100.
For that, you can remove variable d and use variable c instead.
//int d
//d=c-b;
e=b-c%b;
+ 3
#include <iostream>
using namespace std;
int main()
{
int no,x;
cin>>no;
cout<<50-(no%50);
return 0;
}
+ 2
thank you all