コード例 #1
0
PdeAndBoundaryConditions<DIM>::~PdeAndBoundaryConditions()
{
    // Avoid memory leaks if the object was loaded from an archive
    if (mDeleteMemberPointersInDestructor)
    {
        delete mpPde;
        delete mpBoundaryCondition;
    }

    DestroySolution();
}
コード例 #2
0
int main (){

  int nQueens;
  int size;
  int verbose;
  
  Solution* Sol;
  char** PrintMat;
  int hasSol;
  
  int start = 0;
  int limit;

  ParseInput(&nQueens, &size, &verbose);
  
  if(nQueens - size > 1){
    start = 1;
  }
  if(size > 15){
    start = size;
  } 

  for(int i=start; i<size; i++){
    for(int j=0; j<size; j++){
      Sol = NewSolution(size);
      hasSol = SolveQueens(Sol, 0, nQueens);

      start = (nQueens - size > 0);
    }
  }

  if(hasSol)
    printf("%d\n", Sol->nKnights);
  else
    printf("-1\n");

  if(verbose && hasSol){
    PrintMat = AsMatSolution(Sol);
    PrintCharMat(PrintMat, size, size);
    DestroyCharMat(PrintMat, size);
  }

  DestroySolution(Sol);

  return 0;
}