#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:
- ORA-19502: write error on file “”, block number (block size=)
- Error in DESeqDataSet(se, design = design, ignoreRank) : some values in assay are negative
- In R language, for loop or array truncation, the following error occurs only 0’s may be mixed with negative subscripts
- ValueError: Integers to negative integer powers are not allowed.
- socket.error : [errno 10048] and view PID process number and port number
- Copying a param with shape torch. Size ([262, 2048]), parameter size does not match
- ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256,
- raise ValueError(‘Expected input batch_size ({}) to match target batch_size ({}).‘
- The function and usage of argc and argv in C language
- JavaScript removes the number specified in the array
- Error in `./a.out‘: free(): invalid next size (fast): 0x0000000001da8010
- [Solved] CAP_IMAGES: can‘t find starting number (in the name of file)
- Use of rep function in R
- error C2057: expected constant expression (Can the size of an array in C language be defined when the program is running?)
- Error in pom.xml dependency version number in idea
- Tensorflow in function tf.Print Method of outputting intermediate value
- A convenient method to count the total number of query results in MySQL