题解 | #坐标移动#

坐标移动

http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29

#include<bits/stdc++.h> using namespace std;

int main(void) { vector numx; int x=0,y=0; string temp; int a = 0,w=0,s=0,d=0,num = 0,ot =0; string str; while(cin>>str) { int size = str.size(); for(int i=0;i<size;i++) { if(ot==0) if(str[i]!=';') { if(str[i] == 'A') a++; else if(str[i] == 'W') w++; else if(str[i] == 'S') s++; else if(str[i] == 'D') d++; else if(str[i] >= '0'&&str[i]<='9') num++; else ot++; if(a+w+s+d+ot>1) ot=1; temp += str[i]; } if(str[i] == ';') { if(!ot) if(a == 1&& num ==2)//左 { x += stoi(temp.substr(1,2))(-1); //cout<<stoi(temp.substr(1,2))-1<<' '; a=0; num=0; ot = 0; } else if(s == 1&& num ==2)//左 { y+=stoi(temp.substr(1,2))(-1); //cout<<stoi(temp.substr(1,2))-1<<' '; s=0; num=0; ot = 0; } else if(d == 1&& num ==2)//左 { x+=stoi(temp.substr(1,2)); //cout<<stoi(temp.substr(1,2))<<' '; d=0; num=0; ot = 0; } else if(w == 1&& num ==2)//左 { y+=stoi(temp.substr(1,2)); w=0; num=0; ot = 0; } else if(w == 1&& num ==1)//左 { y+=stoi(temp.substr(1,1)); w=0; num=0; ot = 0; } else if(a == 1&& num ==1)//左 { x+=stoi(temp.substr(1,1))-1; w=0; num=0; ot = 0; } else if(s == 1&& num ==1)//左 { y+=stoi(temp.substr(1,1))-1; w=0; num=0; ot = 0; } else if(d == 1&& num ==1)//左 { x+=stoi(temp.substr(1,1)); w=0; num=0; ot = 0; } temp.clear(); ot = 0; a=0;w=0;s=0;d=0;num=0; continue; } } cout<<x<<","<<y<<endl; x=0;y=0; }

}
全部评论

相关推荐

05-25 10:45
门头沟学院 Java
Frank_zhan...:没实习一个项目肯定不够,可以再做一个轮子,技术栈再补一个mq,微服务,整体再换个简历模板,暑期尽量再找一个日常实习
无实习如何秋招上岸
点赞 评论 收藏
分享
07-18 14:34
门头沟学院 Java
感觉招聘要求好高,这都是招什么人才
电气电子小朋友:你都说了这是大疆,无人机顶级企业,薪资30k-50k,要求高是正常的
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务