Note: vector<int> vec = {0, 0, 0}
return true
So I have a solution, it looks like this:
bool check(vector<char> vec)// can't think of a better name
{
char firstChar {vec[0]};
for (char i : vec)
{
if (i != firstChar)
return false;
}
return true;
}
But since I'm a newbie, is there a better solution?
Aucun commentaire:
Enregistrer un commentaire