+ 1
Can someone explain what I did wrong?
I tested the std::list with Ballpark order, but the elements doesn't add Up the the sum and only the first element's used. Sample Input: Water Water Water Output: ~4.28 I think the Problem's either with the std::list and how I gave them values or with the loop I Made to sum them(Through more likely First) https://code.sololearn.com/c73WEibmSJ7T/?ref=app
3 Answers
+ 1
also, try to handl the case where the user enter a whitespace in the end of the string or a double space in between words like:
'Cheeseburger Water '
^ ^
in this case ur prog will output another value different to what we expect.
0
Hi Felix đ
The std Library provides an input function called ws, which consumes whitespace from an input stream:
std::getline(std::cin >> std::ws, input);
use this instead of '' cin >> input;''
0
Amine Laaboudi Thanks I found now all Problems and the Code seems to do his Work. đ