mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-11-13 15:00:46 -05:00
2.3 KiB
2.3 KiB
Hints
General
while
loops are used for indefinite (uncounted) iterationfor
loops are used for definite, (counted) iteration.- The keywords
break
andcontinue
help customize loop behavior. std::to_string()
fromstring
library can be used to convert a integer to string
Also being familiar with the following can help with completing the tasks:
vectors
: indexing, size,<vector>.emplace_back
,<vector>.pop_back()
.string
: using the+
to concatenate strings, integer to string conversion,to_string
.
1. Rounding Scores
While
loops will continue to execute until their test condition evaluates toFalse
.<vector>.back()
will return the last item in avector
.<vector>.pop_back()
will remove the last item in avector
.
2. Non-Passing Students
- A results counter does need to be set up and incremented -- you'll want to
return
the count of non-passing students when the loop terminates.
3. The "Best"
-
- Having an empty
vector
to add the "best" marks to is helpful here.
- Having an empty
<vector>.emplace_back()
can help add things to the resultsvector
.
4. Calculating Letter Grades
- These are lower thresholds. The lower threshold for a "D" is a score of 41, since an "F" is <= 40.
static_cast<int>
without parameters should round off increments nicely.- You are expected to return an array, not a vector.
5. Matching Names to Scores
- If both containers are the same length and sorted the same way, could you use the
index
from one to retrieve avalue
from the other? std::to_string(int)
can be used to convert a number to string.- Don't forget the follow the format of the example's output.
6. A "Perfect" Score
- There may be or may not be a student with a score of 100, and you can't return an empty string without checking all scores.
- The
control flow
statementscontinue
andbreak
may be useful here to move past unwanted values.