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

  Develop class which implements interface

Let the ADT called SquareMatrix. (The matrix can be represented by 2-D array of ints w/ n rows and n columns.) Write specification for ADT as Java interface. Develop the class which implements interface.

  Modify the book class to accommodate multiple authors

modify the Book class to accommodate multiple authors using one of the components from the Java Collection Framework.

  A program that reads a four-digit number from the keyb

Write a program that reads a four-digit number from the keyboard as a string and then converts it into decimal. For example, if the input is 1100, the output should be 12. Hint: Break the string into characters and then convert each character to a va..

  Find the solution of all these java question

find the solution of all these java question

  Implement the application using a singly linked list

Implement the following application using a singly linked list. This application accepts from console and stores a list of 10 names of your friends in the singly linked list

  Savingsaccount and bankaccount objects

The only differences between SavingsAccount and BankAccount objects is that SavingsAccount have an interest rate and can compute interest when necessary. Add an instance variable and a method to SavingsAccount to allow for these items.

  Graphics program that draws 12 strings

Write a graphics program that draws 12 strings, one each for the 12 standard colors, besides Color.WHITE, each in its own color. Provide a class ColorNameViewer and a class ColorNameComponent.

  One acre of land is equivalent to

One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of square feet in a tract of land with 3.5acres.

  Create java program to find number of days left in that year

Create a Java program called "DaysLeftInYear.java" that outputs the number of days left in that year. use the calendar class to represent dates. Use the DateFormat class to display the current date in the output.

  Describe the steps to program development

What is the function of parseFloat and parseInt and what will be result if we send "abcd" through a prompt() input and pass it through parseInt()?

  I had to call a webservice

I had to call a webservice (1st line of code) and then from there created a loop but keep getting an error every time on the .getBusiness - I don't know what I should be using there instead of getBusiness.

  Create a computer class

Create a computer class and assume computers have the following fields: String manufacture, double price, int year

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