Created
October 26, 2014 12:30
-
-
Save henrybear327/e206efab04f83d4b23c1 to your computer and use it in GitHub Desktop.
UVA10409(宗穎).c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<string.h> | |
struct Die | |
{ | |
int top, bottom, north, east, south, west; | |
}; | |
struct Die d; | |
int main() | |
{ | |
int n; | |
char str[10]; | |
while (scanf("%d", &n)!=EOF && n) | |
{ | |
d.top = 1, d.bottom = 6, d.north = 2, d.east = 4, d.south = 5, d.west = 3; | |
while (n--) | |
{ | |
scanf("%s", str); | |
if (str[0] == 's') | |
d.south = d.top, d.top = d.north, | |
d.bottom = 7 - d.top, d.north = 7 - d.south; | |
if (str[0] == 'n') | |
d.bottom = d.north, d.north = d.top, | |
d.top= 7 - d.bottom, d.south = 7 - d.north; | |
if (str[0] == 'w') | |
d.bottom = d.west, d.west = d.top, | |
d.top = 7 - d.bottom, d.east = 7 - d.west; | |
if (str[0] == 'e') | |
d.east = d.top, d.top = d.west, | |
d.bottom = 7 - d.top, d.west = 7 - d.east; | |
} | |
printf("%d\n", d.top); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment