fork download
  1. typedef complex < double > point;
  2. namespace std
  3. {
  4. bool operator < ( const point & a , const point & b )
  5. {
  6. return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  7. }
  8. }
  9. double cross( const point & a , const point & b )
  10. {
  11. return imag( conj(a) * b );
  12. }
  13. double dot( const point & a , const point & b )
  14. {
  15. return real( conj(a) * b );
  16. }
  17. int ccw( point a , point b , point c )
  18. {
  19. b -= a; c -= a;
  20. if( cross( b , c ) > 0 ) return +1; //counter clockwise
  21. if( cross( b , c ) < 0 ) return -1; // clockwise
  22. if( dot( b , c ) < 0 ) return +2; // c -- a -- b ON line
  23. if( norm(b) < norm(c) ) return -2; // a -- b -- c ON line
  24. }
  25. vector < point > convex_hull ( vector < point > ps )
  26. {
  27. int n = ps.size(), k = 0;
  28. sort( ps.begin() , ps.end() );
  29. vector < point > ch ( 2*n );
  30. for( int i = 0 ; i < n ; ch[k++] = ps[i++] ) //lower hull
  31. while( k >= 2 && ccw( ch[k-2] , ch[k-1] , ps[i] ) <= 0 ) --k;
  32. for( int i = n - 2 , t = k + 1 ; i >= 0 ; ch[k++] = ps[i--] ) //upper hull
  33. while( k >= t && ccw( ch[k-2] , ch[k-1] , ps[i] ) <= 0 ) --k;
  34. ch.resize(k-1);
  35. return ch;
  36. }
  37.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:9: error: ‘complex’ does not name a type
 typedef complex < double > point;
         ^
prog.cpp:4:26: error: ‘point’ does not name a type
  bool operator < ( const point & a , const point & b )
                          ^
prog.cpp:4:34: error: ISO C++ forbids declaration of ‘a’ with no type [-fpermissive]
  bool operator < ( const point & a , const point & b )
                                  ^
prog.cpp:4:44: error: ‘point’ does not name a type
  bool operator < ( const point & a , const point & b )
                                            ^
prog.cpp:4:52: error: ISO C++ forbids declaration of ‘b’ with no type [-fpermissive]
  bool operator < ( const point & a , const point & b )
                                                    ^
prog.cpp:4:54: error: ‘bool std::operator<(const int&, const int&)’ must have an argument of class or enumerated type
  bool operator < ( const point & a , const point & b )
                                                      ^
prog.cpp:9:21: error: ‘point’ does not name a type
 double cross( const point & a , const point & b )
                     ^
prog.cpp:9:29: error: ISO C++ forbids declaration of ‘a’ with no type [-fpermissive]
 double cross( const point & a , const point & b )
                             ^
prog.cpp:9:39: error: ‘point’ does not name a type
 double cross( const point & a , const point & b )
                                       ^
prog.cpp:9:47: error: ISO C++ forbids declaration of ‘b’ with no type [-fpermissive]
 double cross( const point & a , const point & b )
                                               ^
prog.cpp: In function ‘double cross(const int&, const int&)’:
prog.cpp:11:21: error: ‘conj’ was not declared in this scope
  return imag( conj(a) * b );
                     ^
prog.cpp:11:27: error: ‘imag’ was not declared in this scope
  return imag( conj(a) * b );
                           ^
prog.cpp: At global scope:
prog.cpp:13:19: error: ‘point’ does not name a type
 double dot( const point & a , const point & b )
                   ^
prog.cpp:13:27: error: ISO C++ forbids declaration of ‘a’ with no type [-fpermissive]
 double dot( const point & a , const point & b )
                           ^
prog.cpp:13:37: error: ‘point’ does not name a type
 double dot( const point & a , const point & b )
                                     ^
prog.cpp:13:45: error: ISO C++ forbids declaration of ‘b’ with no type [-fpermissive]
 double dot( const point & a , const point & b )
                                             ^
prog.cpp: In function ‘double dot(const int&, const int&)’:
prog.cpp:15:21: error: ‘conj’ was not declared in this scope
  return real( conj(a) * b );
                     ^
prog.cpp:15:27: error: ‘real’ was not declared in this scope
  return real( conj(a) * b );
                           ^
prog.cpp: At global scope:
prog.cpp:17:10: error: ‘point’ was not declared in this scope
 int ccw( point a , point b , point c )
          ^
prog.cpp:17:20: error: ‘point’ was not declared in this scope
 int ccw( point a , point b , point c )
                    ^
prog.cpp:17:30: error: ‘point’ was not declared in this scope
 int ccw( point a , point b , point c )
                              ^
prog.cpp:17:38: error: expression list treated as compound expression in initializer [-fpermissive]
 int ccw( point a , point b , point c )
                                      ^
prog.cpp:18:1: error: expected ‘,’ or ‘;’ before ‘{’ token
 {
 ^
prog.cpp:25:1: error: ‘vector’ does not name a type
 vector < point > convex_hull ( vector < point > ps )
 ^
prog.cpp: In function ‘double cross(const int&, const int&)’:
prog.cpp:12:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prog.cpp: In function ‘double dot(const int&, const int&)’:
prog.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty