problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
lintcode::judge_circle::Solution类 参考

#include <lintcode.h>

静态 Public 成员函数

static bool judgeCircle (string &moves)
 

详细描述

在文件 lintcode.h72 行定义.

成员函数说明

◆ judgeCircle()

bool lintcode::judge_circle::Solution::judgeCircle ( string &  moves)
static
参数
movesa sequence of its moves
返回
: if this robot makes a circle

在文件 lintcode.cpp123 行定义.

123 {
124 int x = 0;
125 int y = 0;
126 for(const char ch: moves) {
127 switch(ch) {
128 case 'R':
129 x--;
130 break;
131 case 'L':
132 x++;
133 break;
134 case 'U':
135 y--;
136 break;
137 case 'D':
138 y++;
139 break;
140 default: break;
141 }
142 }
143 return x == 0 && y == 0;
144 }

被这些函数引用 lintcode::judge_circle::TEST().


该类的文档由以下文件生成: