Source (Plain Text)
void graham (vector<Point2>& P, vector<Point2>& H) {

  // Finde den Startpunkt
  int left=0;
  for (int i=1; i < P.size(); i++)

    if (P[i].x < P[left].x) left = i;

  // Sortiere radial um P[left]
  sort (P.begin(), P.end(), cmp_angle (P[left]));

  H.push_back (P[0]);
  H.push_back (P[1]);

  for (int i=2; i < P.size(); ) {

    if (H.size()>=2 && cw (H[H.size()-2], H[H.size()-1], P[i]))

      H.pop_back();
    else {
      H.push_back (P[i]);
      ++i;
    }
  }
}