Question
Computer Science Please turn this code from c++ to java. #include #include #include #include #include using namespace std; const char UP = 0x1; const char
Computer Science
Please turn this code from c++ to java.
#include
using namespace std;
const char UP = 0x1; const char DOWN = 0x2; const char LEFT = 0x4; const char RIGHT = 0x8; const char VISITED = 0x10;
void set_flag(char &cell, const char flag) { cell |= flag; }
bool has_flag(const char &cell, const char flag) { return static_cast
int rand_int(int a, int b) { double N = (double) abs(a - b); int x = a + (int) (N * rand()/(RAND_MAX + 1.0)); return x; }
void dump_maze(const char (&maze)[12][12]) { cout << " _ _ _ _ _ _ _ _ _ _ _ _" << endl; for(int i=0; i<12; ++i) { for(int j=0; j<12; ++j) { cout << (has_flag(maze[i][j], LEFT) ? ' ' : '|'); cout << (has_flag(maze[i][j], DOWN) ? ' ' : '_'); } cout << "|" << endl; } }
void generate_maze(char (&maze)[12][12], pair
static stack< pair
int main(int argc, char *argv[]) { srand(time(NULL)); char maze[12][12] = {0}; generate_maze(maze, make_pair(0,0)); set_flag(maze[0][0], LEFT); set_flag(maze[11][11], DOWN); dump_maze(maze); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started