Problem p00682 (C++) — buggy submission, verdict: Runtime Error

#include <iomanip>
#include <iostream>

class Point {
public:
  Point() : x(0), y(0) {}

  Point(int x, int y) : x(x), y(y) {}

  int x, y;
};

double calcTriangle(const Point &first, const Point &second,
                    const Point &third);

int cross(const Point &first, const Point &second);

double calcArea(Point *array, int start, int end);

int calcVectorCross(const Point &first, const Point &second,
                    const Point &third);

int main() {
  int dataNum = 0;
  while (1) {
    int pointNum;
    std::cin >> pointNum;

    if (pointNum == 0) {
      break;
    }

    dataNum++;

    Point *pointArray = new Point[pointNum];
    for (int i = 0; i < pointNum; i++) {
      int x, y;
      std::cin >> x >> y;
      pointArray[i] = Point(x, y);
    }

    std::cout << dataNum << " " << std::fixed << std::setprecision(1)
              << calcArea(pointArray, 0, pointNum - 1) << std::endl;
  }

  return 0;
}

int calcVectorCross(const Point &first, const Point &second,
                    const Point &third) {
  Point point1(second.x - first.x, second.y - first.y);
  Point point2(third.x - first.x, third.y - first.y);

  return cross(point1, point2);
}

double calcTriangle(const Point &first, const Point &second,
                    const Point &third) {
  return calcVectorCross(first, second, third) / 2.0;
}

int cross(const Point &first, const Point &second) {
  return first.x * second.y - first.y * second.x;
}

double calcArea(Point *array, int start, int end) {
  double area = 0;
  int first = start + 1;
  while (!(first == end)) {
    area += -calcTriangle(array[start], array[first], array[first + 1]);
    first++;
  }
  return area;
}

Error: 0

Fixed submission:

#include <iomanip>
#include <iostream>

class Point {
public:
  Point() : x(0), y(0) {}

  Point(int x, int y) : x(x), y(y) {}

  int x, y;
};

double calcTriangle(const Point &first, const Point &second,
                    const Point &third);

int absolute(int num);

int cross(const Point &first, const Point &second);

double calcArea(Point *array, int start, int end);

int calcVectorCross(const Point &first, const Point &second,
                    const Point &third);

int main() {
  int dataNum = 0;
  while (1) {
    int pointNum;
    std::cin >> pointNum;

    if (pointNum == 0) {
      break;
    }

    dataNum++;

    Point *pointArray = new Point[pointNum];
    for (int i = 0; i < pointNum; i++) {
      int x, y;
      std::cin >> x >> y;
      pointArray[i] = Point(x, y);
    }

    std::cout << dataNum << " " << std::fixed << std::setprecision(1)
              << calcArea(pointArray, 0, pointNum - 1) << std::endl;
  }

  return 0;
}

int calcVectorCross(const Point &first, const Point &second,
                    const Point &third) {
  Point point1(second.x - first.x, second.y - first.y);
  Point point2(third.x - first.x, third.y - first.y);

  return cross(point1, point2);
}

double calcTriangle(const Point &first, const Point &second,
                    const Point &third) {
  return absolute(calcVectorCross(first, second, third)) / 2.0;
}

int absolute(int num) {
  if (num < 0) {
    return -num;
  } else {
    return num;
  }
}

int cross(const Point &first, const Point &second) {
  return first.x * second.y - first.y * second.x;
}

double calcArea(Point *array, int start, int end) {
  double area = 0;
  int first = start + 1;
  int second = first + 1;
  while (!(first == end)) {
    while (calcVectorCross(array[start], array[first], array[second]) > 0) {
      second++;
    }
    area += calcArea(array, first, second);
    area += calcTriangle(array[start], array[first], array[second]);
    first = second;
    second = first + 1;
  }

  return area;
}