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

#include <iostream>
using namespace std;

class CCombi {
public:
  // Public member function
  CCombi(void);
  bool Input(void);
  void InputDataSet(void);
  void PrintCountcombi(void);
  bool CheckPrm(int num, int sum);
  bool CheckEnd(void);
  void CountCombination(void);

private:
  // Private member variable
  static const int NUM_MAX = 100;
  static const int NUM_MIN = 3;
  static const int SUM_MAX = 300;
  int num;
  int sum;
  int countcombi;
};

CCombi::CCombi(void) {
  num = 0;
  sum = 0;
  countcombi = 0;
}

bool CCombi::Input(void) {
  InputDataSet();
  if (CheckPrm(num, sum) == false) {
    return false;
  }

  return true;
}

void CCombi::InputDataSet(void) {
  cin >> num >> sum;

  return;
}

void CCombi::PrintCountcombi(void) {
  cout << countcombi << "\\n";

  return;
}

bool CCombi::CheckPrm(int num, int sum) {
  if ((num < 0) || (num > NUM_MAX) || (sum < 0) || (sum > SUM_MAX)) {
    return false;
  }

  return true;
}

bool CCombi::CheckEnd(void) {
  if ((num == 0) && (sum == 0)) {
    return true;
  } else {
    countcombi = 0;
  }

  return false;
}

void CCombi::CountCombination(void) {
  for (int i = 1; i <= num - 2; i++) {
    for (int j = i + 1; j <= num - 1; j++) {
      for (int k = j + 1; k <= num; k++) {
        if ((i + j + k) == sum) {
          countcombi++;
          break;
        }
      }
    }
  }

  return;
}

int main(void) {
  CCombi combi;

  while (1) {
    if (combi.Input() == false) {
      return -1;
    }
    if (combi.CheckEnd() == true) {
      break;
    }
    combi.CountCombination();
    combi.PrintCountcombi();
  }

  return 0;
}


Error: 255

Fixed submission:

#include <iostream>
using namespace std;

class CCombi {
public:
  // Public member function
  CCombi(void);
  bool Input(void);
  void InputDataSet(void);
  void PrintCountcombi(void);
  bool CheckPrm(int num, int sum);
  bool CheckEnd(void);
  void CountCombination(void);

private:
  // Private member variable
  static const int NUM_MAX = 100;
  static const int NUM_MIN = 3;
  static const int SUM_MAX = 300;
  int num;
  int sum;
  int countcombi;
};

CCombi::CCombi(void) {
  num = 0;
  sum = 0;
  countcombi = 0;
}

bool CCombi::Input(void) {
  InputDataSet();
  if (CheckPrm(num, sum) == false) {
    return false;
  }

  return true;
}

void CCombi::InputDataSet(void) {
  cin >> num >> sum;

  return;
}

void CCombi::PrintCountcombi(void) {
  cout << countcombi << "\\n";

  return;
}

bool CCombi::CheckPrm(int num, int sum) {
  if ((num < NUM_MIN) || (num > NUM_MAX) || (sum < 0) || (sum > SUM_MAX)) {
    return false;
  }

  return true;
}

bool CCombi::CheckEnd(void) {
  if ((num == 0) || (sum == 0)) {
    return true;
  }

  return false;
}

void CCombi::CountCombination(void) {
  for (int i = 1; i <= num - 2; i++) {
    for (int j = i + 1; j <= num - 1; j++) {
      for (int k = j + 1; k <= num; k++) {
        if ((i + j + k) == sum) {
          countcombi++;
          break;
        }
      }
    }
  }

  return;
}

int main(void) {
  CCombi combi;

  while (1) {
    if (combi.Input() == false) {
      return -1;
    }
    if (combi.CheckEnd() == true) {
      break;
    }
    combi.CountCombination();
    combi.PrintCountcombi();
  }

  return 0;
}