public class PJJJeden {
public static void main(String[] args) {
int[][] tab = {{1, 0, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1}};
int ile = 0;
for (int i = 0; i < tab.length; i++)
ile += tab[i].length; //to to samo co inaczej ile=ile+tab[i].length
int[] tab2 = new int[ile];
ile = 0;
for (int i = 0; i < tab.length; i++) {
for (int j = 0; j < tab[i].length; j++) {
tab2[ile] = tab[i][j];
ile++;
}
}
for (int i = 0; i < tab2.length; i++) {
System.out.println(tab2[i]);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter