该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
int main(int argc, char *argv[])
{
struct Touzi tz = {1, 2, 3};
int temp;
char buff[200];
FILE * fp;
print_tz(tz);
if (argc == 2)
fp = fopen(argv[1], "r");
else {
fp = stdin;
printf("%s", prompt);
}
while(fgets(buff, sizeof(buff) - 1, fp) != NULL)
{
temp = tz.top;
buff[strlen(buff) - 1] = '\0';
if (fp != stdin)
puts(buff);
if (strcmp("east", buff) == 0) {
tz.top = tz.west;
tz.west = 7 - temp;
} else if (strcmp("west", buff) == 0) {
tz.top = 7 - tz.west;
tz.west = temp;
} else if (strcmp("north", buff) == 0) {
tz.top = 7 - tz.north;
tz.north = temp;
} else if (strcmp("south", buff) == 0) {
tz.top = tz.north;
tz.north = 7 - temp;
} else {
printf("%s is not a direction\n", buff);
}
print_tz(tz);
if (fp == stdin)
printf("%s", prompt);
}
return 0;
}