About Average word length it get right in test 1, 2, 4 but the other is no what problem with code? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

About Average word length it get right in test 1, 2, 4 but the other is no what problem with code?

https://code.sololearn.com/cw6CQKdHwl2Y/?ref=app

21st Feb 2021, 6:57 AM
Abdullah Said
Abdullah Said - avatar
5 Respuestas
+ 1
round up is done with ceil() not round(). the difference is: round(3.1) = 3 round(3.6) = 4 ceil(3.1) = 4 ceil(3.6) = 4 so change round to ceil. and skip '?' in first test-case if(s[i]=='?') continue; if(s[i]!=' ') c1++; else c2++; cout<<ceil(c1/c2)<<endl;
21st Feb 2021, 8:09 AM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
if the test was well written it would not pass. because of ceil() the 2nd test-case. has 34 characters if you count "..." and 31 if you skip them.(with " " skipped ) there are 7 words in any case. so: 34 / 7 = 4.xx 31/ 7 = 4.xx with ceil() you get 5 every time. so it doesn't matter if you skip them or not. unlike "?" in first case which gives different results if you don't skip it.
21st Feb 2021, 8:38 AM
Bahhaⵣ
Bahhaⵣ - avatar
0
Why I didn't skip '.'
21st Feb 2021, 8:26 AM
Abdullah Said
Abdullah Said - avatar
0
Thanks for effort 💜sorry I exhausted you
21st Feb 2021, 9:19 AM
Abdullah Said
Abdullah Said - avatar
0
no problem, mar7aba.
21st Feb 2021, 9:20 AM
Bahhaⵣ
Bahhaⵣ - avatar