1. 程式人生 > >hdu-1033(格式)

hdu-1033(格式)

ios nbsp pac detail style printf urn 參考 http

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1033

參考文章:https://blog.csdn.net/curson_/article/details/52183782

題意:一開始在點(300,420),然後向下走了10到了(310,420),A表示向右轉,V表示向左轉。

每次用0,1,2,3代表南,東,西,北,表示移動方向。

一開始題目理解錯了,還認為是旋轉變化,看來該學英語了。

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char
s[100100]; int main(void) { int i,j,dir; while(~scanf("%s",s)) { int l=strlen(s); printf("300 420 moveto\n310 420 lineto\n"); i=310,j=420; dir=1; for(int k=0;k<l;k++) { if(s[k]==A) dir=(dir-1)%4; else dir=(dir+1)%4;
if(dir==0) dir=4; if(dir==1) i+=10; // else if(dir==2) j+=10; // else if(dir==3) i-=10; //西 else if(dir==4) j-=10; // printf("%d %d lineto\n",i,j); } printf("stroke\nshowpage\n"); } return 0; }

hdu-1033(格式)