+ 1
Code coatch test cases green, but fail.(SOLVED)
I have done the Halloween candy code cotch. The test cases visible to me are green, and the expected output is correct. Still i'm told to try again. How can this be? #include <iostream> using namespace std; int main() { int houses; cin>>houses; //your code goes here float average; average = 2.0/houses; cout << int((average * 100 + 0.5)); return 0; }
5 Respostas
+ 6
Maybe hidden test cases don't match with your solution.
Btw, can we see your code?
+ 6
Output should be rounded up to the nearest integer.
Try this
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int houses;
cin>>houses;
//your code goes here
float average;
average = 2.0/houses;
cout << ceil(average * 100 );
return 0;
}
+ 2
average = 2.0/houses;
Change this line as:
average = 2.0/(float)houses;
Or: add #include <math.h>
and change the last line as:
cout<<ceil(average*100);
I hope, it helps. Happy coding!
+ 2
That worked. Surprised it was so specific about how to solve it. My initial sollution should work, but then again, i can not see the testcases that failed.