Java Recursion Array and Max sum path -
ok, ive been working on assignment while , cant started because of brick wall keep running into. need take data file , recursively fill different 2d int arrays data example .txt file might have:
2 <-- number of 2d arrays have 3 <-- l x w of 2d array 1 2 4 <-| 4 7 9 <-|-- data fill 2d array 2 1 6 <-| 2 <-- l x w of 2d array 3 4 <-|-- data fill 2d array 5 9 <-|
so thinking i'd use size add index in order skip on data blocks have been put array. 1 array have 1 2 4 4 7 9 2 1 6 in me work , other have 3 4 5 9 ive tried many ways has recursive , able work data in format..any ideas?
string[size][size] myarray = new string[size][size]; int row = 0 ; int column = 0; bufferedreader br = null; try { string line; br = new bufferedreader(new filereader("the file path here!")); //for each line in file while ((line= br.readline()) != null) { //split on white space string[] row = line.split("\\s+"); //column index for(int =0; < row.length; i++){ string context = row[i]; myarray[row][column] = context; row++; column++; if(row == size) row = 0; if(column == size) column = 0; } } } catch (ioexception e) { e.printstacktrace(); } { try { if (br != null)br.close(); } catch (ioexception ex) { ex.printstacktrace(); } }
Comments
Post a Comment