Created
January 31, 2015 00:54
-
-
Save SilverEzhik/b8bd1fce8af89c11df13 to your computer and use it in GitHub Desktop.
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 <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
const int LEFT = 4; | |
const int UP = 2; | |
const int RIGHT = 6; | |
const int DOWN = 8; | |
const char WALL = '#'; | |
const char FREE = '-'; | |
const char EXIT = 'e'; | |
int main() { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ | |
char maze[13]; | |
//cout << "WTF"; | |
//cin >> maze; | |
//cout << maze[LEFT]; | |
for(int i = 0; i < 13; i++) | |
{ | |
cin >> maze[i]; | |
//if (maze[i] == '#') cout << '#'; | |
//cout << "this is maze[" << i << "]: " << maze[i] << '\n'; | |
//cout << maze[i]; | |
} | |
if(maze[UP] == EXIT) | |
{ | |
cout << "UP"; | |
return 0; | |
} | |
else if (maze[LEFT]== EXIT) | |
{ | |
cout << "LEFT"; | |
return 0; | |
} | |
else if (maze[DOWN]== EXIT) | |
{ | |
cout << "DOWN"; | |
return 0; | |
} | |
else if (maze[RIGHT]== EXIT) | |
{ | |
cout << "RIGHT"; | |
return 0; | |
} | |
// Move | |
if(maze[UP] == FREE) | |
{ | |
cout << "UP"; | |
return 0; | |
} | |
else if (maze[RIGHT]== FREE) | |
{ | |
cout << "RIGHT"; | |
return 0; | |
} | |
else if (maze[LEFT]== FREE) | |
{ | |
cout << "LEFT"; | |
return 0; | |
} | |
else if (maze[DOWN]== FREE) | |
{ | |
cout << "DOWN"; | |
return 0; | |
} | |
//cout << "\nThe end."; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment