My code no dot work as might | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

My code no dot work as might

why this code return 18 with input 8 0 -10 0 2 4 0 3 3 0 7 0 4 5 5 -9 9 , should return 22.5 https://code.sololearn.com/cSpgRYB8oj5D/?ref=app

6th Mar 2018, 12:44 PM
Максим
Максим - avatar
4 Answers
0
As given above try changing at least one variable in the right side expression to double
6th Mar 2018, 6:05 PM
Ravi Chandra Enaganti
Ravi Chandra Enaganti - avatar
0
when you are computing values for s1 and s2, typecast atleast one variable in the right side expression to double. This is because in C++, integer expressions always result in integers unless type casted to double. Eg. S_1 = (max_1 - min_1) / 2.0d
6th Mar 2018, 1:29 PM
Ravi Chandra Enaganti
Ravi Chandra Enaganti - avatar
0
how can i fix it!
6th Mar 2018, 6:02 PM
Максим
Максим - avatar
0
thank you
7th Mar 2018, 2:08 AM
Максим
Максим - avatar