class Solution {
public :
bool judgeCircle(string moves){
int shuzhi=0;
int shuiping=0;
for (int i = 0; i < moves.size(); i++)
{
/* code */
if (moves[i]=='U')
{
shuzhi++;
}else if (moves[i]=='D')
{
/* code */
shuzhi--;
}
else if (moves[i]=='L')
{
/* code */
shuiping--;
}else if (moves[i]=='R')
{
/* code */
shuiping++;
}
}
if (shuiping==0&&shuzhi==0)
{
/* code */
return true;
}else{
return false;
}
}
};
机器人能否回到原点
最新推荐文章于 2024-07-08 22:12:26 发布