Ищете решение, как выйти из цикла в нужном месте - PullRequest
0 голосов
/ 07 июня 2019

Ладно, ребята, так что сначала я хочу найти три freePositions, одна из них sortedSystem.BooleanCellSystem [row] [column], а затем вернуться и изменить строку, мой вопрос: куда мне положить {break;}, чтобы я мог получить 3freePosition с другой строкой.Спасибо :)

public void FindingFreeCells(SortingSystem sortedSystem, int number)
{
  int freePositions = 0;
  double tempCoef = 0;

  for (int row = 0; row < sortedSystem.BooleanCellSystem.Length; row++)
  {
    for (int column = 0; column < sortedSystem.BooleanCellSystem[row].Length; column++)
    {
      if (sortedSystem.BooleanCellSystem[row][column] != true)
      {
        for (int n = column; n < number; n++)
        {
          if (sortedSystem.BooleanCellSystem[row][column] == true)
          {
            break;
          }
          for (int k = 1; k < 3; k++)
          {
            if (sortedSystem.BooleanCellSystem[row][column + k] != true)
            {
              tempCoef += 5;
            }
          }
          if (n == number - 1)
          {
            freePositions++;
            AvailableCell temp = new AvailableCell();
            temp.FirstRow = row;
            temp.FirstColumn = column;
            temp.CellsRequired = number;
            temp.PriorityCoeff = row + column + tempCoef;
            AvailableCellsList.Add(temp);
          }
        }
      }               
    }
  }
}
...