hdu1033

时间:2023-03-09 04:43:23
hdu1033
#include<stdio.h>
#include<string.h>
const int MAXN=200;
char str[MAXN];
int main()
{
int x,y;
while(scanf("%s",&str)!=EOF)
{
int len=strlen(str);
int x=310,y=420;
int p=1;//标记走向,一开始是X轴正方向
printf("300 420 moveto\n310 420 lineto\n");
for(int i=0;i<len;i++)
{
switch(p)
{
case 1://X轴正方向
if(str[i]=='V') p=2,y+=10;
else p=-2,y-=10;
break;
case 2://Y轴正方向
if(str[i]=='V') p=-1,x-=10;
else p=1,x+=10;
break;
case -1://X轴负方向
if(str[i]=='V') p=-2,y-=10;
else p=2,y+=10;
break;
case -2:
if(str[i]=='V') p=1,x+=10;
else p=-1,x-=10;
break;
}
printf("%d %d lineto\n",x,y);
}
printf("stroke\nshowpage\n"); }
return 0; }