自测时报错: In file included from foo.cc:1: Solution.h: In lambda function: Solution.h:57:21: warning: comparison of integer expressions of different signedness: 'std::vector::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare] 57 | if(A.size() != n) { | ~~~~~~~^~ 可见引用文件Solution.h中出现了语法错误,麻烦老师修改一下

1 条评论

  • @ 2025-10-17 17:16:11

    报错信息显示 long unsigned int和int类型不匹配 A.size()返回的数据类型是size_t,为无符号整数类型,int为有符号整数类型,比较时可能会出现bug,请同学们注意

    感兴趣的话可以运行如下代码

    #include<iostream>
    using namespace std;
    int main(){
      size_t a = 20000;
      int b = -1;
      if(a > b)
        cout << "20000 > -1" << endl;
      else
        cout << "20000 <= -1" << endl;
      return 0;
    }
    

    并思考运行结果

    • 1