예제 #1
0
파일: D.cpp 프로젝트: xyiyy/icpc
int main() {
    int nRound;
    int i, j;
    FILE *fp;
    char pFir[MAX_LENGTH], pSec[MAX_LENGTH];
    Maze maze;


    scanf("%d", &nRound);

    for (i = 0; i < nRound; i++) {
        maze.Clean();

        scanf("%s%s", pFir, pSec);
        for (j = 0; j < MAX_LENGTH; j++) {
            if (pFir[j + 1] == '/0') break;
            if (pFir[j] == 'W') maze.Move();
            if (pFir[j] == 'L') maze.TurnLeft();
            if (pFir[j] == 'R') {
                if (pFir[j + 1] == 'R') {
                    maze.Turn180();
                    j++;
                }
                else {
                    maze.TurnRight();
                }
            }
        }
        maze.MoveOnly();
        maze.Turn180();
        for (j = 0; j < MAX_LENGTH; j++) {
            if (pSec[j + 1] == '/0') break;
            if (pSec[j] == 'W') maze.Move();
            if (pSec[j] == 'L') maze.TurnLeft();
            if (pSec[j] == 'R') {
                if (pSec[j + 1] == 'R') {
                    maze.Turn180();
                    j++;
                }
                else {
                    maze.TurnRight();
                }
            }
        }
        maze.MoveOnly();
        printf("Case #%d:\n", i + 1);
        maze.Print();
    }
    return 0;
}
예제 #2
0
파일: TextMaze.cpp 프로젝트: vladyash/Stuff
int main(int argv, char** argc)
{
	//TODO: Maze generator
	Room r1, r2, r3, r4;
	r1.m_right.m_direction = r2.m_id;
	r2.m_down.m_direction = r3.m_id;
	r3.m_left.m_direction = r4.m_id;
	r4.m_isFinal = true;

	Maze m;
	m.Add(r1); m.Add(r2); m.Add(r3); m.Add(r4);
	m.Current();

	char input;
	while (true)
	{
		cin >> input;
		if ( input == 'q' )
		{
			cout << "BYE! Exiting in 5 seconds\n";
			Sleep(5000);
			return 0;
		}
		m.Move (input);
		if (m.isFinal())
		{
			cout << "You're in a final room. Hoooray! Exiting in 5 seconds\n";
			Sleep(5000);
			return 0;
		}
	}
	
	return 0;
}