Example #1
0
int main() {
  int N;
  scanf("%d", &N);
  std::vector<int> X(N), Y(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &X[i], &Y[i]);
  }
  printf("%lld\n", getTotalArea(N, X, Y));
  return 0;
}
int main(int argc, char * argv[])
{
  if (argc < 3)
    {
      fprintf(stderr, "Missing file name.\n");
      return 1;
    }
  FILE * finput = fopen(argv[1], "r");
  if (finput == NULL)
    {
      fprintf(stderr, "Cannot open file.\n");
      return 2;
    }
  FILE * fcheck = fopen(argv[2], "r");
  if (fcheck == NULL)
    {
      fprintf(stderr, "Cannot open file.\n");
      return 2;
    }

  LinkList list = LinkList_Construct();

  // Reads rectangle dimensions from file into linked list
  while(readRectDimension(finput, list));
  fclose(finput);

  // Reads rectangle positions from standard input
  if (!readRectPositions(fcheck, list))
    {
      // Something is wrong
      printf("Incorrect output.\n");
      return 1;
    }
  fclose(fcheck);

  // Validates the whole list
  if (!validateRectangles(list))
    {
      return 1;
    }

  // Calculates total area
  long totalArea = getTotalArea(list);
  long boundArea = getBoundArea(list);
  printf("Area sum: %ld\n", totalArea);
  printf("Area required: %ld\n", boundArea);

  // Release Linked List
  LinkList_Destruct(list, NULL);
  return 0;
}
ofRectangle ofxWidget::getControlTotalArea(){
	return getTotalArea(styleEnabled);
}