#2924. C++-编译-warning: comparison between signed and unsigned...

C++-编译-warning: comparison between signed and unsigned...

Background

Description

5.warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
    (void)argc,(void)argv;
    vector<int>vec;
    vec.push_back(2);
    int a=1;
    if( a == vec.size() ){
        cout << "Hello World!" << endl;
    }
    return 0;
}

warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if( a == vec.size() )
           ^

警告:int和unsigned integer进行比较。

这种警告可以通过强转,使等号左右两边数据类型一致。

Format

Input

Output

Samples



Limitation

1s, 1024KiB for each test case.