Compile Error

foo.cc: In function ‘int main()’:
foo.cc:9:20: error: reference to ‘min’ is ambiguous
    9 |                 if(min>a[i])min=a[i],mini=i;
      |                    ^~~
In file included from /nix/gcc-14.3.0/include/c++/14.3.0/algorithm:61,
                 from stdc++.h:51:
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5696:5: note: candidates are: ‘template<class _Tp, class _Compare> _Tp std::min(initializer_list<_Tp>, _Compare)’
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5686:5: note:                 ‘template<class _Tp> _Tp std::min(initializer_list<_Tp>)’
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
In file included from /nix/gcc-14.3.0/include/c++/14.3.0/algorithm:60:
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:281:5: note:                 ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:233:5: note:                 ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
foo.cc:3:12: note:                 ‘int min’
    3 | int a[101],min=INT_MAX,max=INT_MIN,maxi,mini;
      |            ^~~
foo.cc:9:29: error: reference to ‘min’ is ambiguous
    9 |                 if(min>a[i])min=a[i],mini=i;
      |                             ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5696:5: note: candidates are: ‘template<class _Tp, class _Compare> _Tp std::min(initializer_list<_Tp>, _Compare)’
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5686:5: note:                 ‘template<class _Tp> _Tp std::min(initializer_list<_Tp>)’
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:281:5: note:                 ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:233:5: note:                 ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
foo.cc:3:12: note:                 ‘int min’
    3 | int a[101],min=INT_MAX,max=INT_MIN,maxi,mini;
      |            ^~~
foo.cc:10:20: error: reference to ‘max’ is ambiguous
   10 |                 if(max<a[i])max=a[i],maxi=i;
      |                    ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5716:5: note: candidates are: ‘template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)’
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5706:5: note:                 ‘template<class _Tp> _Tp std::max(initializer_list<_Tp>)’
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:303:5: note:                 ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:257:5: note:                 ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
foo.cc:3:24: note:                 ‘int max’
    3 | int a[101],min=INT_MAX,max=INT_MIN,maxi,mini;
      |                        ^~~
foo.cc:10:29: error: reference to ‘max’ is ambiguous
   10 |                 if(max<a[i])max=a[i],maxi=i;
      |                             ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5716:5: note: candidates are: ‘template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)’
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5706:5: note:                 ‘template<class _Tp> _Tp std::max(initializer_list<_Tp>)’
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:303:5: note:                 ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:257:5: note:                 ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
foo.cc:3:24: note:                 ‘int max’
    3 | int a[101],min=INT_MAX,max=INT_MIN,maxi,mini;
      |                        ^~~
foo.cc:12:26: error: reference to ‘max’ is ambiguous
   12 |         cout<<maxi<<" "<<max<<endl<<mini<<" "<<mina;
      |                          ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5716:5: note: candidates are: ‘template<class _Tp, class _Compare> _Tp std::max(initializer_list<_Tp>, _Compare)’
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algo.h:5706:5: note:                 ‘template<class _Tp> _Tp std::max(initializer_list<_Tp>)’
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:303:5: note:                 ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/nix/gcc-14.3.0/include/c++/14.3.0/bits/stl_algobase.h:257:5: note:                 ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
foo.cc:3:24: note:                 ‘int max’
    3 | int a[101],min=INT_MAX,max=INT_MIN,maxi,mini;
      |                        ^~~
foo.cc:12:48: error: ‘mina’ was not declared in this scope; did you mean ‘mini’?
   12 |         cout<<maxi<<" "<<max<<endl<<mini<<" "<<mina;
      |                                                ^~~~
      |                                                mini

信息

递交者
类型
递交
题目
P2568 找最大数和最小数
语言
C++
递交时间
2026-02-09 19:42:13
评测时间
2026-02-09 19:42:13
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes