POJ 2556

题意:一个点从(300,420)走到(310,420),方向向右,然后遇到A向右转90度再直走10,反之,向左转90度再直走10.

题解:同上

View Code
 1 #include<cstdio>

 2 #include<cstring>

 3 using namespace std;

 4 int dr[][2]={10,0,0,-10,-10,0,0,10};

 5 int main()

 6 {

 7     char s[250];

 8     while(gets(s))

 9     {

10         int x=310,y=420,d=0;

11         printf("300 420 moveto\n310 420 lineto\n");

12         for(int i=0;s[i]!='\0';i++)

13         {

14             if(s[i]=='A')

15                 d=(d+1)%4;

16             else

17                 d=(d+3)%4;

18             x+=dr[d][0];

19             y+=dr[d][1];

20             printf("%d %d lineto\n",x,y);

21         }

22         printf("stroke\nshowpage\n");

23     }

24     return 0;

25 }

你可能感兴趣的:(poj)