华为机试-坐标移动
来源:互联网 发布:windows更新卡住了 编辑:程序博客网 时间:2024/06/14 03:18
#include<iostream>#include<string>#include<math.h>#include<vector>#include<map>#include<set>using namespace std;typedef struct point{ int posx; int posy;}pos;void SplitSting(const string& strInput, vector<string> &vec, const string& c){ string::size_type pos1 = 0; string::size_type pos2 = strInput.find(c); while(string::npos != pos2) { vec.push_back(strInput.substr(pos1, pos2-pos1)); pos1 = pos2 + c.size(); pos2 = strInput.find(c, pos1); }}int main(){ string input; while(cin>>input) { pos pointer = {0,0}; vector<string> vecInput; SplitSting(input, vecInput, ";"); for(int i = 0; i<vecInput.size(); i++) { bool isInvalid = false; int sum=0; if(vecInput[i].size()>1 && vecInput[i].size()<=3) { for(int j = 1; j <=vecInput[i].size() - 1; j++) { if(vecInput[i][j]>='0' && vecInput[i][j]<='9') sum = sum*10 +(vecInput[i][j] - '0'); else { isInvalid = true; break; } } if(!isInvalid) { switch(vecInput[i][0]) { case 'A': pointer.posx -= sum; break; case 'S': pointer.posy -= sum; break; case 'W': pointer.posy += sum; break; case 'D': pointer.posx += sum; break; default: break; } } } } cout<<pointer.posx<<','<<pointer.posy<<endl; } return 0;}
阅读全文
0 0
- 华为机试-坐标移动
- 华为机试-坐标移动
- [华为机试练习题]9.坐标移动
- 华为机试——坐标移动
- Java----------华为机试--------------坐标移动
- 华为机试——坐标移动
- 华为机试题:坐标移动
- 华为机试在线训练-牛客网(10)坐标移动
- 牛客网_华为机试_017_坐标移动
- 华为机试题--16.坐标移动
- 华为测试 坐标移动
- 华为oj 坐标移动
- 华为OJ 坐标移动
- 华为oj 坐标移动
- 华为Oj 坐标移动
- 华为oj 坐标移动
- 华为oj--坐标移动
- 华为OJ----坐标移动
- 关于嵌入式小组的相关问题
- 传输线端接
- 对于JXL读取Excel精度丢失问题
- 【NOIP2017提高A组模拟9.26】逗气
- 多线程基础
- 华为机试-坐标移动
- 13.笔记go语言——并发调度器
- HDU2795 Billboard题解
- (转)什么是DevOps?阿里专家为你来解读
- UNIX环境高级编程笔记之高级I/O
- 关于“百度未授权使用地图API”的解决方案
- 求二叉树的深度 递归 非递归
- 进程管理--消息队列
- Google MapReduce