Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int curRow = 0; curRow < 8; curRow++) //current row and column.
- for (int curCol = 0; curCol < 8; curCol++)
- {
- for (int steprow = -1; steprow <= 1; steprow++) //amount to step rows and colums by.
- for (int stepcol = -1; stepcol <= 1; stepcol++)
- {
- int k = showCount(curRow, curCol, steprow, stepcol, array);
- if (k > maxScore)
- {
- maxScore = k;
- maxRow = curRow;
- maxCol = curCol;
- }
- }
- }
- int showCount(int row, int col, int stepRow, int stepCol, int array[8][8])
- {
- if(stepRow == 0 && stepCol == 0)
- return 0;
- if(array[row + stepRow][col + stepCol] != 1)
- return 0;
- int count = 0;
- while(row <= 8 && row >= -1 && col <= 8 && col >= -1)
- {
- row = row + stepRow;
- col = col + stepCol;
- if((row < 0) || (row > 7) || (col < 0) || (col > 7))
- {
- count = 0;
- break;
- }
- else
- {
- if (array[row][col] == 1)
- {
- count++;
- }
- else
- {
- if (array[row][col] == 0)
- {
- count = 0;
- break;
- }
- else
- {
- break;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment