#include <leetcode.h>
|
static vector< int > | findBall (vector< vector< int > > &grid) |
|
◆ findBall()
vector< int > leetcode::where_will_the_ball_fall::Solution::findBall |
( |
vector< vector< int > > & | grid | ) |
|
|
static |
在文件 leetcode.cpp 第 3464 行定义.
3464 {
3465 const int m = grid.size();
3466 const int n = grid[0].size();
3468 for(
int i = 0; i <
n; i++) {
3469 int current_x = 0;
3470 int current_y = i;
3471 int dir = 1;
3472 while(true) {
3473 if(current_x == m) {
3475 break;
3476 }
3477 if(current_x < 0 || current_y < 0 || current_y >= n) {
3479 break;
3480 }
3481 if(dir == 0) {
3482
3483 if(grid[current_x][current_y] == 1) {
3485 break;
3486 }
3487 dir = 1;
3488 } else if(dir == 1) {
3489
3490 if(grid[current_x][current_y] == 1) {
3491 dir = 2;
3492 } else {
3493 dir = 0;
3494 }
3495 } else {
3496
3497 if(grid[current_x][current_y] == 1) {
3498 dir = 1;
3499 } else {
3501 break;
3502 }
3503 }
3504 if(dir == 0) {
3505
3506 current_y--;
3507 } else if(dir == 1) {
3508
3509 current_x++;
3510 } else {
3511
3512 current_y++;
3513 }
3514 }
3515 }
3517 }
vector< vector< int > > ans
被这些函数引用 leetcode::where_will_the_ball_fall::TEST(), leetcode::where_will_the_ball_fall::TEST() , 以及 leetcode::where_will_the_ball_fall::TEST().
该类的文档由以下文件生成: