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 |
贴下本人代码。。。#include "stdio.h" #include "memory.h" int temp[6]; int direct[5][6]={{1,0,3,2,4,5},{2,3,1,0,4,5},{3,2,0,1,4,5},{4,5,2,3,1,0},{5,4,2,3,0,1}}; int d[6][3]={{1,0,0},{0,1,0},{0,0,1},{-1,0,0},{0,-1,0},{0,0,-1}}; int code(char * s){ switch(s[0]){ case 'l': return 1; case 'r': return 2; case 'u': return 3; case 'd': return 4; case 'b': return 0; default : return 5; } } int main(void){ char str[20]; int m,n,t,result1[6]={0,3,4,1,2,5},x,y,z,l,i,j,result[6]; scanf("%d",&m); while(m--){ scanf("%d",&n); x=y=z=0; memcpy(result,result1,sizeof(result)); while(n--){ scanf("%s%d",str,&t); l=code(str); if(l!=5){ for(i=0;i!=6;++i) temp[i]=result[direct[l][i]]; memcpy(result,temp,sizeof(temp)); } x+=d[result[0]][0]*t,y+=d[result[0]][1]*t,z+=d[result[0]][2]*t; } printf("%d %d %d %d\n",x,y,z,result[0]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator