java - Using flood fill algorithm to erase specific elements of a textfile -


I have a problem with my classes where I will have to take all the "cancer" cells of a text file and flood algorithm Get rid of them using

This is the right question:

Create a program that reads a 15x15 grid text file, which shows human cells featured cells with a plus sign goes ???? +++ If they are healthy cells, and sign in with a zero - ???? If they are cancerous, only the plus signs will be included in the rows and columns outside the grid. Note: Use the Flood Algorithm to determine this information.

So far, I can get at least one cancer cell area to convert to "" , but I can not find another one yet. That's it. This is an example of how it should look:

  Import java.io.buffferedReader; Import java.io.fileReader; Import java.io.IOException; Import java.util.ArrayList; Create Public Class Flood Intra {// Global Variable (Grid and Blob Seas) that are accessible anywhere within Class FlatIntro Public Static Character new grid [] []; Public Static Ent Blob Size; Public static zero main (string [] args throws IOException {string [] grid = new string [15]; NewGrid = new character [15] [15]; BufferedReader = New BufferedReader (New FileReader ("location.txt")); String str = faucet; ArrayList & LT; String & gt; Line = new arreelist & lt; String & gt; (); Int i = 0; While ((str = in.readLine ()) = = null {grid [i] = str; // System.out.println (str); i ++;} // For every row in the grid so far (Int x = 0; x & lt; grid.length; x ++) can print every line listed above (int y = 0; y & lt; grid [x]]; length (); y + +) {NewGrid [x] [y] = grid [x] .charAt (y);}} Print the current grid display (); Blob blob size = 0 to determine the size of // variable; // Select a random element in the array which is not with // border and remove the drops at that place. Tip: If the blank is selected, then the size of the blob is 0 and nothing is drawn int blobRow = (int) (Math.rendum) * 13 + 1); int blobCol = (int) (Math.Random) (* 13 + 1); System.out.println ("" + Blobro + "," BlobCol + "Blanks will be removed.) Fill the flood (Blowborough, Blob Koll); System.out.println (" Blob "+ Blob size +" contains item "); System.out.println (" The new grid is: "); // New Grid DisplayGrid print;} Fill public static zero floods (int row, int colle) { If (Nigrid [Punk [Cola]. Axles ('-')) {nigrid [row] [cola] = ''; BlobSize ++; Fill the flood (line-1, cola-1); Fill the flood (line-1, cola); Fill the flood (line-1, cola + 1); Fill the flood (row, column -1); Fill the flood (row, cola + 1); Fill the flood (Row + 1, Colonel -1); Fill the flood (row + 1, cola); Fill the flood (Row + 1, Color + 1); }} Public static zero performance grid () {string output = ""; {Int (line = 0; row & lt; = 14; line ++) {for (col col; 0; col & lt; = 14; col ++) {output + = newGrid [row] [cola]; } Output + = "\ n"; } System.out.println (Output); }}   

The txt file is being used here:

  +++++++++++++++++ - ++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++ ----- +++ +++++ ----- +++++ ++++++ ------ +++ ++++ +++ ----- ++++++++++++++++++++++++++++++++++++++++++  
     Int Blobro = (Int.) (Math. Rendum) * 13 + 1); Int blobCol = (int) (Math.Random) * 13 + 1);   

can not end at a - , so nothing like this happens (if you get a it does not go into this statement ) + ).

You can see that it fills the condition of the cancer correctly if you pass it to the valid coordinates.

In addition, you should actually flood a few times (once for each cancer spot) something like this:

  1. a - (
  2. If found:
    • Increase one counter (since you need to output the number of cancer spots)
    • Proceed with flooding from there
    • and repeat with # 1

Comments

Popular posts from this blog

jasper reports - How to center align barcode using jasperreports and barcode4j -

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -