+ 1
Cpp code improvement
How can this code be improved? Just finished working on it: https://sololearn.com/compiler-playground/cDd5kN7rsC2Q/?ref=app
9 odpowiedzi
+ 4
What I'm sure of is that you definitely can pack the repetitive inputs at the beginning into a loop iterating over the coins, making the prompt string be mentioned in the code only once.
And you can really simplify this output case list section into just getting the index of unique message to display and right coin indexes to use inside it, then just composing the message at the end.
This would make the code a lot shorter and cleaner.
+ 3
what is the right weight?
Also, the output does not make sense if all of the inputs are equal.
I would probably put every input in an array to make getting the inputs simpler, then do a more generalised math operation to get the result rather than comparing manually.
+ 3
Tell the user what the code is about and what to input in comments when you start your code even before the #include so he does not have to scroll all along the code and look for the cin tags
+ 1
I would recommend improving variable names
+ 1
That's the last thing I would look like. What I'm looking for is a better structure, approach.
+ 1
So a better way to get the same output?
+ 1
Thanks for guidance
+ 1
i suggest to write it in a good manner so it will become readable
0
Alhaaz, I suggest you practice giving constructive criticizm so it will become helpful