【题意】我觉得这题意才是最难的地方。但明白后其实很简单就是给你一个坐标(300,420),初始方向------->(310,420),A 是右旋, V 是左旋,让你把整个过程的坐标求出。
【题解】这我就不多说了,一般看懂题目是肯定可以A 掉的;纯模拟。
<pre code_snippet_id="361782" snippet_file_name="blog_20140524_1_134506" name="code" class="cpp">#include<cstdio>
int main()
{
char ch;
while(scanf("%c",&ch)!=EOF)
{
int tot,num,way=1;tot=310;num=420;//way,记录当前方向,tot是纵坐标,num是横坐标(上是加,下是减);
printf("300 420 moveto\n");
printf("310 420 lineto\n");
while(ch!='\n')
{
if(ch=='A'){
if(way==1)num-=10,way=2;
else if(way==2)tot-=10,way=3;
else if(way==3)num+=10,way=4;
else if(way==4)tot+=10,way=1;
printf("%d %d lineto\n",tot,num);
}else {
if(way==1)num+=10,way=4;
else if(way==2)tot+=10,way=1;
else if(way==3)num-=10,way=2;
else if(way==4)tot-=10,way=3;
printf("%d %d lineto\n",tot,num);
}
ch=getchar();
}
printf("stroke\n");
printf("showpage\n");
}
// for(;;);
return 0;
}