See More

package arrayToString; //This program converts an array into a string in a spiral order. // Az alábbi program az input téglalap alakú tömb // elemeit csigavonalban sorbarendezve egy String-be (eredmény) írja át. public class arrayToString { public static void main(String[] args) { int[][] input = new int[][]{ {1,2,3}, {5,6,7}, {9,10,11}, {12,13,14}, }; String result = ""; String section = ""; int[][] work = input; while(work.length>0){ section = copy(work); result = result + section; if(work.length>1 && work[0].length>1){ work = deleting(work); }else { break; } } System.out.println(result); } public static int[][] deleting(int[][] table){ int height = table.length; int length = table[0].length; int[][] answer = new int[height-2][length-2]; for(int i=0; i