Guest User

Untitled

a guest
Jun 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. for (int curRow = 0; curRow < 8; curRow++) //current row and column.
  2. for (int curCol = 0; curCol < 8; curCol++)
  3. {
  4. for (int steprow = -1; steprow <= 1; steprow++) //amount to step rows and colums by.
  5. for (int stepcol = -1; stepcol <= 1; stepcol++)
  6. {
  7. int k = showCount(curRow, curCol, steprow, stepcol, array);
  8. if (k > maxScore)
  9. {
  10. maxScore = k;
  11. maxRow = curRow;
  12. maxCol = curCol;
  13. }
  14.  
  15. }
  16. }
  17.  
  18.  
  19.  
  20.  
  21. int showCount(int row, int col, int stepRow, int stepCol, int array[8][8])
  22. {
  23. if(stepRow == 0 && stepCol == 0)
  24. return 0;
  25.  
  26. if(array[row + stepRow][col + stepCol] != 1)
  27. return 0;
  28.  
  29. int count = 0;
  30.  
  31. while(row <= 8 && row >= -1 && col <= 8 && col >= -1)
  32. {
  33. row = row + stepRow;
  34. col = col + stepCol;
  35. if((row < 0) || (row > 7) || (col < 0) || (col > 7))
  36. {
  37. count = 0;
  38. break;
  39. }
  40. else
  41. {
  42. if (array[row][col] == 1)
  43. {
  44. count++;
  45. }
  46. else
  47. {
  48. if (array[row][col] == 0)
  49. {
  50. count = 0;
  51. break;
  52. }
  53. else
  54. {
  55. break;
  56. }
  57. }
  58. }
  59.  
  60. }
Add Comment
Please, Sign In to add comment