Need the build function.use recursion

Assignment Help JAVA Programming
Reference no: EM13168401

Implement remaining function. Everything else is provided. Use given material to receive points. Need the build function. Use Recursion!!!

#include "stdio.h"

#define SIZE 10

struct cell_type {

int row;

int col;

int dir;

};

typedef struct cell_type Cell;

 

Cell sol[SIZE*SIZE];

 

 

int maze[SIZE][SIZE] = {

1, 1, 1, 1, 1, 1, 1, 1, 1, 1,

1, 0, 0, 0, 1, 1, 0, 0, 0, 1,

1, 0, 1, 0, 0, 1, 0, 1, 0, 1,

1, 0, 1, 1, 0, 0, 0, 1, 0, 1,

1, 0, 0, 1, 1, 1, 1, 0, 0, 1,

1, 1, 0, 0, 0, 0, 1, 0, 1, 1,

1, 0, 0, 1, 1, 0, 0, 0, 0, 1,

1, 0, 1, 0, 0, 0, 0, 1, 1, 1,

1, 0, 0, 0, 1, 0, 0, 0, 0, 1,

1, 1, 1, 1, 1, 1, 1, 1, 1, 1

};

 

 

void build(int);

void printSolution(int);

int cellOk(int);

int getNextCell(int);

 

void main(void)

{

sol[0].row = 1;

sol[0].col = 1;

sol[0].dir = 0;

 

build(0);

}

 

 

void build(int n)

{

//Implement this

}

 

 

 

 

void printSolution(int n)

{

int i;

 

printf("\nA solution was found at:\n");

for (i = 0; i <= n; i++)

printf("(%d, %d) ", sol[i].row, sol[i].col);

printf("\n\n");

}

 

 

int getNextCell(int n)

{

sol[n + 1].row = sol[n].row;

sol[n + 1].col = sol[n].col;

sol[n + 1].dir = 0;

 

switch (sol[n].dir) {

case 0:

sol[n].dir = 'e';

sol[n + 1].col++;

return 1;

case 'e':

sol[n].dir = 's';  

sol[n + 1].row++;

return 1;

case 's':

sol[n].dir = 'w';

sol[n + 1].col--;

return 1;

case 'w':

sol[n].dir = 'n';

sol[n + 1].row--;

return 1;

case 'n':

return 0;

}

return 0;

}

 

 

int cellOk(int n)

{

int i;

 

if (maze[sol[n + 1].row][sol[n + 1].col])

return 0;

 

for (i = 0; i<n; i++)

if (sol[n + 1].row == sol[i].row && sol[n + 1].col ==

sol[i].col)

return 0;

 

return 1;

}

 

 

Reference no: EM13168401

Questions Cloud

The greatest common divisor of the fibonacci number : what is the greatest common divisor of the fibonacci numbers f100 and f101 by Euclid algorithm
The provided code reads two sequences of numbers : The provided code reads two sequences of numbers. In this task, you are asked to write a function to insert these numbers into two separate doubly linked lists so that the data are in ascending order
The packing list describes the ideal contents : The packing list describes the ideal contents of each package, but it is not always possible to include the ideal number of each item. Therefore, the actual items included in each package should be tracked. A package can contain many different ite..
Variable of type string that has been assigned : Assume that word is a variable of type string that has been assigned a value. Write an expression whose value is a string consisting of the last three characters of the value word. So if if the value if word were "biggest" the expression's value w..
Need the build function.use recursion : Implement remaining function. Everything else is provided. Use given material to receive points. Implement remaining function. Everything else is provided. Use given material to receive points. Implement remaining function. Everything else is provide..
Output the starting position and length : X Strings: Input a string. Output the starting position and length of the first occurrence of the longest substring of capital Xs in that string. The first letter is in position 1.
Determine the optimal yearly production plan : Determine the optimal yearly production plan for the ore processed by the Luna Mining Company and prepare a budgeted income statement before taxes for LMC for 2015, and determine the pretax profit on sales percentage.
Calculate the molar entropy of evaporation of ccl3f : Trichlorofluoromethane (CCl3F) boils at 23.8C, and its molar heat of vaporization is 24.8 kJ/mol. Calculate the molar entropy of evaporation of CCl3F(l).
Write a string expression that parenthesizes the value : Given a string varible word, write a string expression that parenthesizes the value of word. So if the word contains "sadly" the value of the expression would be the string "(sadly)".

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd