We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
the variable n should be of type unsigned and, I would write it as while(n--) as n is never used inside of the loop. Furthermore, query could be an unsigned short.
Thirdly, the line
s.at(student)=0;
should be
s.erase(studentFound);
according to what is asked. Although the behaviour is the same, notice that we are freeing some memory with the second option.
Maps-STL
You are viewing a single comment's thread. Return to all comments →
Finally someone able to write code and format it!
Firstly, these should be removed:
Secondly, because of
the variable
n
should be of typeunsigned
and, I would write it aswhile(n--)
asn
is never used inside of the loop. Furthermore,query
could be anunsigned short
.Thirdly, the line
should be
according to what is asked. Although the behaviour is the same, notice that we are freeing some memory with the second option.
Forthly, since C++11, the line
should be replaced by
or, prior to C++11, by
Finally the
break;
ofcase 3
is useless and I would output a character 0 ('0'
) instead of aconst char*
("0"
) when displaying the grade.