I'm writing a simple C++17 program that compares two vectors of integers.
e.g., I have two vectors: a
represents the number -1, b
25
std::vector<int> a = {-1};
std::vector<int> b = {2, 5};
if(a < b) std::cout << "a < b" << std::endl;
else if(a > b) std::cout << "a > b" << std::endl;
else std::cout << "a = b" << std::endl;
The output produced by the previous piece of code is a < b
, and it is correct.
Let us consider now the following example:
std::vector<int> a = {-1, 9};
std::vector<int> b = {-1, 9, 9};
if(a < b) std::cout << "a < b" << std::endl;
else if(a > b) std::cout << "a > b" << std::endl;
else std::cout << "a = b" << std::endl;
Here the output is a < b
as well, but since -19 > -199 I would like it to be a > b
.
There is a way to solve this? For example, I thought of converting the two vectors into integers and comparing them, but I can't figure out how to do that.