Error in comparing the size function of STL with negative number

using namespace std;
int main()
	int x=0;
	int y=v.size()-2;
	int z=q.size()-2;
	printf("%d %d\n",x,y);
	printf("%d %d\n",x<(v.size()-2),x<y);
	printf("\n%d %d\n",x,z);
	printf("%d %d\n",x<(q.size()-2),x<z);
    return 0;

program run results are as follows:

it is obvious there is a problem, the reason is that the size function the result is unsigned number, into negative becomes a big number. The solution is to store the results in a variable, so that won’t happen.
[c++] unsigned type and negative comparison

Read More: