Skip to content

Instantly share code, notes, and snippets.

@henrybear327
Created October 24, 2014 15:35
Show Gist options
  • Save henrybear327/be5934e393c1a7d9adfd to your computer and use it in GitHub Desktop.
Save henrybear327/be5934e393c1a7d9adfd to your computer and use it in GitHub Desktop.
ACM10409(陳冠儒).c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int n,north,west,east,south,top,bottom,tempbottom,temptop;
char side[10];
while(scanf("%d",&n)==1 && n!=0)
{
top=1;
bottom=6;
north=2;
south=5;
east=4;
west=3;
while(n)
{
scanf("%s",&side);
if(strcmp(side,"north")==0)
{
tempbottom=bottom;
temptop=top;
top=south;
bottom=north;
north=temptop;
south=tempbottom;
}
else if(strcmp(side,"south")==0)
{
tempbottom=bottom;
temptop=top;
top=north;
bottom=south;
north=tempbottom;
south=temptop;
}
else if(strcmp(side,"east")==0)
{
tempbottom=bottom;
temptop=top;
top=west;
bottom=east;
east=temptop;
west=tempbottom;
}
else if(strcmp(side,"west")==0)
{
tempbottom=bottom;
temptop=top;
top=east;
bottom=west;
east=tempbottom;/*要用tempbottom和temptop*/
west=temptop;
}
else{
}
n--;
}
printf("%d\n",top);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment