I am trying to make my code compare two vectors. Both vectors will be compared with the same amount of ints. I want it to output Yes if all the ints in redCups are less than GreenCups. And output No if any cup at all in the redCups is larger than greenCups.
Am I tackling this right?
bool beb = true;
for (int i = 0; i < numCups; i++)
{
if (redCups[i]<greenCups[i])
{
beb = false;
}
}
if (beb == true)
{
cout << "Yes" << endl;
}
if else ( beb == false)
cout << "No" << endl;
You can use the
std::equalalgorithm to compare each pair of elements from two containers. By default it returnstrueif all pairs are equal but it’s easy to test each pair forlessorless_equalinstead.