Compile Error

foo.cc:3:11: error: ‘double y1’ redeclared as different kind of entity
    3 | double x1,y1,x2,y2,distance;
      |           ^~
In file included from /nix/glibc-2.38-44-dev/include/features.h:503,
                 from /nix/gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/os_defines.h:39,
                 from /nix/gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/c++config.h:679,
                 from /nix/gcc-13.2.0/include/c++/13.2.0/cassert:43,
                 from stdc++.h:33:
/nix/glibc-2.38-44-dev/include/bits/mathcalls.h:224:1: note: previous declaration ‘double y1(double)’
  224 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
foo.cc: In function ‘int main()’:
foo.cc:6:13: warning: format ‘%lf’ expects argument of type ‘double*’, but argument 3 has type ‘double (*)(double) noexcept’ {aka ‘double (*)(double)’} [-Wformat=]
    6 | scanf("%lf%lf%lf%lf", &x1,&y1,&x2,&y2);
      |           ~~^             ~~~
      |             |             |
      |             double*       double (*)(double) noexcept {aka double (*)(double)}
foo.cc:7:1: error: reference to ‘distance’ is ambiguous
    7 | distance = sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) );
      | ^~~~~~~~
In file included from /nix/gcc-13.2.0/include/c++/13.2.0/bits/stl_algobase.h:66,
                 from /nix/gcc-13.2.0/include/c++/13.2.0/algorithm:60,
                 from stdc++.h:51:
/nix/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator_base_funcs.h:148:5: note: candidates are: ‘template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)’
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
foo.cc:3:20: note:                 ‘double distance’
    3 | double x1,y1,x2,y2,distance;
      |                    ^~~~~~~~
foo.cc:7:37: error: invalid operands of types ‘double(double) noexcept’ {aka ‘double(double)’} and ‘double’ to binary ‘operator-’
    7 | distance = sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) );
      |                                   ~~^~~
      |                                   |  |
      |                                   |  double
      |                                   double(double) noexcept {aka double(double)}
foo.cc:7:45: error: invalid operands of types ‘double(double) noexcept’ {aka ‘double(double)’} and ‘double’ to binary ‘operator-’
    7 | distance = sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) );
      |                                           ~~^~~
      |                                           |  |
      |                                           |  double
      |                                           double(double) noexcept {aka double(double)}
foo.cc:9:19: error: reference to ‘distance’ is ambiguous
    9 | printf("%.3lf\n", distance);
      |                   ^~~~~~~~
/nix/gcc-13.2.0/include/c++/13.2.0/bits/stl_iterator_base_funcs.h:148:5: note: candidates are: ‘template<class _InputIterator> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)’
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
foo.cc:3:20: note:                 ‘double distance’
    3 | double x1,y1,x2,y2,distance;
      |                    ^~~~~~~~

信息

递交者
类型
递交
题目
P1647 距离
语言
C++
递交时间
2024-03-26 22:09:03
评测时间
2024-03-26 22:09:03
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes