leetcode657
bool judgeCircle(string moves) {
int V = ;//垂直位移
int H = ;//水平位移
for (auto m : moves)
{
if (m == 'U')
{
V++;
}
else if (m == 'D')
{
V--;
}
else if (m == 'L')
{
H--;
}
else if (m == 'R')
{
H++;
}
}
if (V == && H == )
{
return true;
}
else
{
return false;
}
}
leetcode657的更多相关文章
- [Swift]LeetCode657. 机器人能否返回原点 | Robot Return to Origin
There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its mov ...
- Leetcode657.Robot Return to Origin机器人能否返回原点
在二维平面上,有一个机器人从原点 (0, 0) 开始.给出它的移动顺序,判断这个机器人在完成移动后是否在 (0, 0) 处结束. 移动顺序由字符串表示.字符 move[i] 表示其第 i 次移动.机器 ...
随机推荐
- codeforces 705B:Spider Man
Description Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a ...
- svg_path
1. path 的 d属性中,M的大/小写貌似不影响图形显示效果(至少现在[20160108]我测试下来是这样[chrome 版本 47.0.2526.80 m]):L/H/V 的大小写 是影响图形显 ...
- Codeforces 888D Almost Identity Permutations:错排公式
题目链接:http://codeforces.com/problemset/problem/888/D 题意: 给定n,k,问你有多少种1到n的排列,满足至少有n-k个a[i] == i. (4 &l ...
- web自动化:元素定位(二)
一. 实例 如何定位到下图第二个"抢投标",有一种方法是利用xpath定位 //a[@href="/loan/loan_detail/Id/7190.html" ...
- hdu 1846 Brave Game(bash)
Brave Game Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- java maven、springmvc、mybatis 搭建简单Web项目学习笔记
前言: 空余的时间,学学 Java,没准哪天用的到: 环境搭建折腾了好几天,总算搞顺了,也做个学习笔记,以防后面会忘记: 一.安装文件及介绍 JDK:jdk1.8.0 77 eclipse-maven ...
- 关于stl advance函数移动步数超过容器大小(越界)的研究
今天使用advance遇到个问题,当advance移动步数超过容器大小时,表现的结果居然不一样. 再来看下stl源码 template<typename _BidirectionalIterat ...
- OpenCV教程【001 Mat显示图片】
#include <opencv2\opencv.hpp> #include <iostream> #include <string> using namespac ...
- 树莓派(Linux)与镜像源
树莓派学习笔记--修改树莓派软件源 1. linux 镜像源文件 >> vim /etc/apt/sources.list 可在树莓派官网 http://www.raspbian.org/ ...
- memcached数据库
Python-memcached的基本使用