由买买提看人间百态

topics

全部话题 - 话题: ncolors
(共0页)
g***j
发帖数: 1275
1
来自主题: JobHunting版 - 这题到底什么意思?
Implement the “paint fill” function that one might see on many image
editing programs. That is, given a screen (represented by a 2-dimensional
array of Colors), a point, and a new color, fill in the surrounding area
until you hit a border of that color.
我看到最近版上不好题目提到了 150上提到的答案如下,我有几个疑问
1 什么叫“until you hit a border of that color”
2 为什么只考虑四个点?不是8个点?8个点有重复的吧?
3 递归的时候这四个点的顺序不一样,会有问题么?
We can implement this algorithm recursively:
1 enum Color {
2 Black, White, Red, Yellow, Green
3 }
4 boolean Paint... 阅读全帖
l*****n
发帖数: 246
2
来自主题: JobHunting版 - G 店面
没什么思路,想这样做,不知道会不会被人鄙视:
public int[][] generateRandomBoard(int NColors, int N, int M) {
int[][] board = new int[N][M];
boolean isEnd = false;
while(!isEnd){
generateRandomBoard(board, NColors);
isEnd = checkBoard(board);
}
return board;
}
private void generateRandomBoard(int[][] board, int NColors) {
Random rm = new Random();
int N = board.length;
int M = board[0].length;
for(int i=0; i for(int j=0; j int te... 阅读全帖
b**********5
发帖数: 7881
3
来自主题: JobHunting版 - G 店面
Generate a random starting board for Bejeweled:
Constraints:
1) No 3-in-a-rows of a particular color (horizontally or vertically)
2) At least one valid starting move (i.e., can swap two cells to get a 3-in-
a-row).
int[][] generateRandomBoard(int NColors, int N, int M)
(共0页)