Convert a C++ code to Java
in
Programming Questions
•
10 months ago
Hi , I have a question,
I have a C++ code, how I do to convert it to java code?
- typedef struct {
- int y;
- int x;
- } loc_t;
- typedef struct {
- double Q[MAX_ACTIONS];
- double sumQ;
- double maxQ;
- } stateAction_t;
- const loc_t dir[MAX_ACTIONS]={
- { -1, 0}, /* N */
- { -1, 1}, /* NE */
- { 0, 1}, /* E */
- { 1, 1}, /* SE */
- { 1, 0}, /* S */
- { 1, -1}, /* SW */
- { 0, -1}, /* W */
- { -1, -1} /* NW */
- };
- // Map
- int grid[Y_MAX][X_MAX]={
- { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
- { -1, 1, 1, 1, 1, -1, 1, 1, 1, -1 },
- { -1, 1, 1, -1, 1, -1, 1, -1, 1, -1 },
- { -1, 1, 1, -1, 1, -1, 1, -1, 1, -1 },
- { -1, 1, 1, -1, 1, -1, 1, -1, 1, -1 },
- { -1, 1, 1, -1, 1, -1, 1, -1, 1, -1 },
- { -1, 1, 1, -1, 1, -1, 1, -1, 1, -1 },
- { -1, 1, 1, -1, 1, -1, 1, -1, 1, -1 },
- { -1, -1, 1, -1, 1, 1, 1, -1, 99, -1 },
- { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }
- };
-
loc_t start={1, 1};loc_t end={8, 8};
I´d tray to programing in java but it give some errors as you can see next:
illegal initializer for IA_Bot.loc_t
illegal initializer for <none>
this is the peace of the code with errors.
- static int loc_t dir[] = {
- { -1, 0}, /* N */
- { -1, 1}, /* NE */
- { 0, 1}, /* E */
- { 1, 1}, /* SE */
- { 1, 0}, /* S */
- { 1, -1}, /* SW */
- { 0, -1}, /* W */
- { -1, -1} /* NW */
- };
- loc_t start={1, 1};
- loc_t end={3, 8};
I would thank for the help
1