##题意##
你一开始在(300420)这个点,向四个方向走,每次走10步,第一次你向下走了10步,然后看输入,若是A就是向右拐,V就是左拐。
[原题地址](https://cn.vjudge.net/problem/23596/origin)
参考博客
##代码及思路##
/*author:Mason.Z
source:HDU1033
point:注意每时每刻你面对哪边。
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<map>
#define MAXN 1000000
using namespace std;
int main()
{
char s[205];
int dir;//表示方向 0 1 2 3
int t;
int x,y;
while(scanf("%s",s)!=EOF){
printf("300 420 moveto\n310 420 lineto\n");
dir=3;
x=310;
y=420;//已知的初始坐标
//说明,该坐标系的方向的正向为东y,南x
//这是向下走了10之后的坐标
for(t=0;t<strlen(s);t++){
if(s[t]=='A')dir=(dir+1)%4;
else dir=(dir+7)%4;//此处感觉为G++的bug,只好这样写了,等价于dir=(dir-1)%4;
if(dir==0)
y-=10;//西
if(dir==1)
x-=10;//北
if(dir==2)
y+=10;//东
if(dir==3)
x+=10;//南
printf("%d %d lineto\n",x,y);
}
printf("stroke\nshowpage\n");
}
return 0;
}