Compile Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:15:23: error: call of overloaded 'abs(std::__cxx11::basic_string<char>::size_type)' is ambiguous
   15 |                 if(abs(a.size()-b.size())>1){
      |                    ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12/bits/std_abs.h:38,
                 from /usr/include/c++/12/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:41,
                 from /in/foo.cc:1:
/usr/include/stdlib.h:861:12: note: candidate: 'int abs(int)'
  861 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/c++/12/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/12/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/12/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/12/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/12/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/in/foo.cc:20:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |                         for(int i=0;i<b.size();i++){
      |                                     ~^~~~~~~~~
/in/foo.cc:33:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |                 for(int i=0;i<b.size();i++){
      |                             ~^~~~~~~~~

信息

递交者
类型
递交
题目
P2628 相似字符串4级1 2024.3
语言
C++
递交时间
2025-11-23 16:02:57
评测时间
2025-11-23 16:02:57
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes