I wanted to challenge myself to add a post fix to the level number for Triple X, instead of writing ‘level 1’ it allows you to do ‘1st level’. You just have to pass in a number and it spits out the postfix (i.e. 1 -> st for 1st, 22 -> nd for 22nd and so forth). Feel free to add it to yours and try to integate it or just break it down. Here’s the code:
std::string DeterminePostFix(int Number)
{
std::string PostFix;
if (Number % 10 == 1 && (Number / 10) % 10 != 1)
{
PostFix = "st";
}
else if (Number % 10 == 2 && (Number / 10) % 10 != 1)
{
PostFix = "nd";
}
else if (Number % 10 == 3 && (Number / 10) % 10 != 1)
{
PostFix = "rd";
}
else
{
PostFix = "th";
}
return PostFix;
}
Edits: formatting, figuring out how the forum works, and a quick change to handle the 11-13 cases