69,382
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
void main()
{
int n;
char p[10];
char c[1024];
while(true)
{
scanf("%d", &n);
if(n==0)
{
return;
}
int i;
scanf("\n", &i);
for(i=0; i<n; ++i)
{
gets(p);
c[i] = *p;
}
int up = 1;
int down = 6;
int north = 2;
int west = 3;
int east = 4;
int south = 5;
int *p1;
int *p2;
int *p3;
int *p4;
p2 = &down;
p4 = &up;
for(i=0; i<n; ++i)
{
if(c[i] == 'n')
{
p1 = &north;
p3 = &south;
}
if(c[i] == 's')
{
p1 = &south;
p3 = &north;
}
if(c[i] == 'e')
{
p1 = &east;
p3 = &west;
}
if(c[i] == 'w')
{
p1 = &west;
p3 = &east;
}
int temp;
temp = *p1;
*p1 = *p4;
*p4 = *p3;
*p3 = *p2;
*p2 = temp;
}
printf("%d\n", up);
}
return;
}