Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 终于对了，贴下代码吧，注意输出的位置，我中间就OLE了好几次

Posted by mingruoyuan at 2009-06-27 17:59:07 on Problem 1835 and last updated at 2009-06-27 17:59:54
```#include<stdio.h>
#include<string.h>
char s[10];
int step,t,n,i,x,y,z,left,right,up,down,back,forward;
void move(int fangxiang,int reach)
{
if(fangxiang==0) x+=reach;
if(fangxiang==1) y+=reach;
if(fangxiang==2) z+=reach;
if(fangxiang==3) x-=reach;
if(fangxiang==4) y-=reach;
if(fangxiang==5) z-=reach;
}
int main()
{
int temp;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
x=0;
y=0;
z=0;
forward=0;
left=4;
right=1;
up=2;
down=5;
back=3;
while(n--)
{
scanf("%s %d",s,&step);
if(s[0]=='f')
move(forward,step);
if(s[0]=='b')
{
move(back,step);
temp=back;
back=forward;
forward=temp;
temp=left;
left=right;
right=temp;
}
if(s[0]=='l')
{
move(left,step);
temp=forward;
forward=left;
left=back;
back=right;
right=temp;
}
if(s[0]=='r')
{
move(right,step);
temp=forward;
forward=right;
right=back;
back=left;
left=temp;
}
if(s[0]=='u')
{
move(up,step);
temp=forward;
forward=up;
up=back;
back=down;
down=temp;
}
if(s[0]=='d')
{
move(down,step);
temp=forward;
forward=down;
down=back;
back=up;
up=temp;
}
}
printf("%d %d %d %d\n",x,y,z,forward);
}
return 0;
}```

Followed by: