记录详情

Compile Error

foo.cc:6:10: error: 'vector' was not declared in this scope
    6 | int find(vector<int>& v, int val)
      |          ^~~~~~
foo.cc:4:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    3 | #include<cmath>
  +++ |+#include <vector>
    4 | using namespace std;
foo.cc:6:17: error: expected primary-expression before 'int'
    6 | int find(vector<int>& v, int val)
      |                 ^~~
foo.cc:6:26: error: expected primary-expression before 'int'
    6 | int find(vector<int>& v, int val)
      |                          ^~~
foo.cc:6:33: error: expression list treated as compound expression in initializer [-fpermissive]
    6 | int find(vector<int>& v, int val)
      |                                 ^
foo.cc: In function 'int main()':
foo.cc:26:2: error: 'vector' was not declared in this scope
   26 |  vector<int> v(n),temp(n);
      |  ^~~~~~
foo.cc:26:2: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
foo.cc:26:9: error: expected primary-expression before 'int'
   26 |  vector<int> v(n),temp(n);
      |         ^~~
foo.cc:29:8: error: 'v' was not declared in this scope
   29 |   cin>>v[i];
      |        ^
foo.cc:30:3: error: 'temp' was not declared in this scope; did you mean 'mktemp'?
   30 |   temp[i]=v[i];
      |   ^~~~
      |   mktemp
foo.cc:34:16: error: reference to 'find' is ambiguous
   34 |   swap+=fabs(i-find(v,temp[i]));
      |                ^~~~
In file included from /usr/include/c++/9/algorithm:62,
                 from foo.cc:2:
/usr/include/c++/9/bits/stl_algo.h:3930:5: note: candidates are: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3930 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                 from /usr/include/c++/9/bits/basic_ios.h:37,
                 from /usr/include/c++/9/ios:44,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from foo.cc:1:
/usr/include/c++/9/bits/streambuf_iterator.h:373:5: note:                 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)'
  373 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
foo.cc:6:5: note:                 'int find'
    6 | int find(vector<int>& v, int val)
      |     ^~~~
foo.cc:34:21: error: 'v' was not declared in this scope
   34 |   swap+=fabs(i-find(v,temp[i]));
      |                     ^
foo.cc:34:23: error: 'temp' was not declared in this scope; did you mean 'mktemp'?
   34 |   swap+=fabs(i-find(v,temp[i]));
      |                       ^~~~
      |                       mktemp
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
4 排序中的交换次数
语言
C++
递交时间
2021-12-30 22:35:04
评测时间
2021-12-30 22:35:04
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes