i am writing a 2D array of integers to represent a swamp, heres the question
write a 2D array of integers to represent a swamp. Every value of 0 represents quicksand while every value of 1 represents solid ground. Your job will be to follow the trail of 1's (solid ground) to the edge of the swamp - or until it dead ends. You will take one step at a time in any direction as long as that step is onto solid ground ( 1 ), and not into quicksand ( 0 ). Put simply, you are dropped into the swamp onto a block of solid ground and starting there must follow the trail of safe steps one at a time until you either reach the edge of the swamp (rescued) or reach a dead end (stranded). You are guaranteed the following: 1) There are no cycles in your path to freedom or dead end (thus no backtracking/recursion needed). 2) You will start out on a block of solid ground. 3) There is only one possible path to take, and thus only one possible correct output for any given swamp.
heres what i have so far....
/*
Program9.java
*/
import java.io.*;
import java.util.*;
public class Program9
{
public static void main(String[] args)
{
int myRow=2, myCol=3; // you are dropped into the swamp at: [2][3]
// ########################################…
This is what i have so far, now how do i write the method that
// LOOKS AT EVERY ADJACENT SQUARE TO SEE IF IT'S A 1
// IF IT IS, THEN THE CURRENT X,Y IS CHANGED TO -1 (i.e. BEEN HERE)
// AND THE COORDS ARE CHANGED TO THOSE OF THE NEARBY SQAURE WITH A 1 IN IT
// IF NO SAFE STEP IS FOUND THEN JUST RETURN FALSE.
1
Expert's answer
2012-11-19T08:46:29-0500
Unfortunately, your question requires a lot of work and cannot be done for free. Submit it with all requirements as an assignment to our control panel and we'll assist you.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment