Error in comparing the size function of STL with negative number

#include<stdio.h>
#include<math.h>
#include<vector>
#include<queue>
using namespace std;
vector<int>v;
queue<int>q;
int main()
{
	v.push_back(1);
	q.push(1);
	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: