Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:三方向定位:头 脸 及 左脸 任意一个转向可以用3个方向中的一个或其相反表示 相反为(n+3)%6In Reply To:三方向定位:头 脸 及 左脸 任意一个转向可以用3个方向中的一个或其相反表示 相反为(n+3)%6 Posted by:wsy217 at 2009-04-25 20:00:32 > #include<stdio.h> > int x,y,z; > int dir,hdir,lfdir; > void go(int a,int b) > { > switch(a) > { > case 0: > x+=b; > break; > case 1: > y+=b; > break; > case 2: > z+=b; > break; > case 3: > x-=b; > break; > case 4: > y-=b; > break; > case 5: > z-=b; > break; > } > } > > int main() > { > char inp[10]; > int dis,num,total,n; > scanf("%d",&total); > while(total--) > { > dir=0; > hdir=2; > lfdir=4; > x=0; > y=0; > z=0; > int tem; > scanf("%d",&num); > while(num--) > { > scanf("%s%d",inp,&dis); > switch(inp[0]) > { > case 'f': > break; > case 'b': > dir=(dir+3)%6; > lfdir=(lfdir+3)%6; > break; > case 'l': > tem=dir; > dir=lfdir; > lfdir=(tem+3)%6; > break; > case 'r': > tem=dir; > dir=(lfdir+3)%6; > lfdir=tem; > break; > case 'u': > tem=dir; > dir=hdir; > hdir=(tem+3)%6; > break; > case 'd': > tem=dir; > dir=(hdir+3)%6; > hdir=tem; > break; > } > go(dir,dis); > } > printf("%d %d %d %d\n",x,y,z,dir); > } > return 0; > } > > > > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator