1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 using namespace std; 6 const int Max = 250; 7 int ansx[Max],ansy[Max]; 8 //0,1,2,3表示方向,顺时针标注 9 void ans(int tx,int ty, int dir,int id) 10 { 11 if(dir == 0){ 12 ansx[id+1] = tx+10; 13 ansy[id+1] = ty; 14 } 15 else if(dir == 1){ 16 ansx[id+1] = tx; 17 ansy[id+1] = ty+10; 18 } 19 else if(dir == 2){ 20 ansx[id+1] = tx-10; 21 ansy[id+1] = ty; 22 } 23 else if(dir == 3){ 24 ansx[id+1] = tx; 25 ansy[id+1] = ty-10; 26 } 27 } 28 int main() 29 { 30 int dir = 0; 31 char query[Max]; 32 while(~scanf("%s",query)) 33 { 34 dir = 0; 35 ansx[0] = 310,ansy[0] = 420; 36 int len = strlen(query); 37 for(int i = 0; i < len; i++) 38 { 39 if(query[i]=='V') { 40 dir = (dir+5)%4; 41 ans(ansx[i],ansy[i],dir,i); 42 } 43 else if(query[i]=='A'){ 44 dir = (dir+3)%4; 45 ans(ansx[i],ansy[i],dir,i); 46 } 47 } 48 printf("300 420 moveto "); 49 for(int i = 0; i <= len; i++){ 50 printf("%d %d lineto ",ansx[i],ansy[i]); 51 } 52 printf("stroke showpage "); 53 } 54 return 0; 55 }