The problem is not difficult, the counter-clockwise time attention, WA has been many times
WA's Code, error
1#include <cstdio>2#include <cstring>3 using namespacestd;4 structpoint{5 intXinty;6}p[3];7 intMain ()8 {9 Charc[205];Ten while(~SCANF ("%s", C)) { Oneprintf"420 moveto\n310 420 lineto\n"); A -p[0].x= -;p [0].y=420;p [1].x=310;p [1].y=420; - for(intI=0; I<strlen (c); i++){ the if(c[i]=='A'){ - if(p[i%3].x==p[i%3+1].x) { -p[i%3+2].y=p[i%3+1].y; -p[i%3+2].x=p[i%3+1].x+p[i%3+1].y-p[i%3].y; + } - Else{ +p[i%3+2].x=p[i%3+1].x; Ap[i%3+2].y=p[i%3+1].y-p[i%3+1].x+p[i%3].x; at } - } - Else if(c[i]=='V'){ - if(p[i%3].x==p[i%3+1].x) { -p[i%3+2].y=p[i%3+1].y; -p[i%3+2].x=p[i%3+1].x-p[i%3+1].y+p[i%3].y; in } - Else{ top[i%3+2].x=p[i%3+1].x; +p[i%3+2].y=p[i%3+1].y+p[i%3+1].x-p[i%3].x; - } the } *printf"%d%d lineto\n", p[i%3+2].x,p[i%3+2].y); $ }Panax Notoginseng -printf"stroke\nshowpage\n"); the } + A return 0; the}
AC Code included
1#include <cstdio>2#include <cstring>3 using namespacestd;4 5 intMain ()6 {7 Charc[205];8 while(~SCANF ("%s", C)) {9printf"420 moveto\n310 420 lineto\n");Ten intx=310, y=420, len=0; One for(intI=0; I<strlen (c); i++){ A - if(c[i]=='V'){ - the Switch(len) { - Case 0: y+=Ten; Break; - Case 1: x+=Ten; Break; - Case 2: y-=Ten; Break; + Case 3: x-=Ten; Break; - } +Len= (len+3)%4;// A } at Else if(c[i]=='A'){ - Switch(len) { - Case 2: y+=Ten; Break; - Case 1: x-=Ten; Break; - Case 0: y-=Ten; Break; - Case 3: x+=Ten; Break; in } -Len= (len+1)%4; to } +printf"%d%d lineto\n", x, y); - } the *printf"stroke\nshowpage\n"); $ }Panax Notoginseng - return 0; the}
HDU 1033 Edge