SHOW:
|
|
- or go back to the newest paste.
1 | package com.Shan; | |
2 | ||
3 | public class Main { | |
4 | ||
5 | int maxX = 30 | |
6 | int maxY = 30 | |
7 | ||
8 | public static void main(String[] args) { | |
9 | - | int tab[][] = new int[30][30]; |
9 | + | |
10 | ||
11 | ||
12 | int tab[][] = new int[maxX][maxY]; | |
13 | ||
14 | for(int i = 0; i < tab.length; i++){ | |
15 | for(int j = 0; j < tab.length; j++){ | |
16 | tab[i][j] = 0; | |
17 | } | |
18 | } | |
19 | ||
20 | tab[0][15] = 1; | |
21 | // tab[0][11] = 1; | |
22 | // tab[0][16] = 1; | |
23 | ||
24 | for(int i = 1; i < tab.length-1; i++){ | |
25 | for(int j = 1; j < tab.length-1; j++){ | |
26 | ||
27 | int lewy = tab[i-1][sprawdz(j-1)] | |
28 | int srodkowy = tab[i-1][j] | |
29 | int prawy = tab[i-1][sprawdz(j+1)] | |
30 | ||
31 | ||
32 | ||
33 | //tutaj na dole zamiast j-1 daj lewy j to srodkowy j+1 to prawy czyli if (prawy == 1) && srodkowy == 1... | |
34 | ||
35 | if(tab[i-1][j-1]==1 && tab[i-1][j]==1 && tab[i-1][j+1]==1) | |
36 | tab[i][j] = 0; | |
37 | ||
38 | if(tab[i-1][j-1]==1 && tab[i-1][j]==1 && tab[i-1][j+1]==0) | |
39 | tab[i][j] = 1; | |
40 | ||
41 | if(tab[i-1][j-1]==0 && tab[i-1][j]==0 && tab[i-1][j+1]==1) | |
42 | tab[i][j] = 0; | |
43 | ||
44 | if(tab[i-1][j-1]==1 && tab[i-1][j]==0 && tab[i-1][j+1]==0) | |
45 | tab[i][j] = 1; | |
46 | ||
47 | if(tab[i-1][j-1]==0 && tab[i-1][j]==1 && tab[i-1][j+1]==1) | |
48 | tab[i][j] = 1; | |
49 | ||
50 | if(tab[i-1][j-1]==0 && tab[i-1][j]==1 && tab[i-1][j+1]==0) | |
51 | tab[i][j] = 0; | |
52 | ||
53 | if(tab[i-1][j-1]==0 && tab[i-1][j]==0 && tab[i-1][j+1]==1) | |
54 | tab[i][j] = 1; | |
55 | ||
56 | if(tab[i-1][j-1]==0 && tab[i-1][j]==0 && tab[i-1][j+1]==0) | |
57 | tab[i][j] = 0; | |
58 | } | |
59 | } | |
60 | ||
61 | for(int i = 0; i < tab.length; i++){ | |
62 | for(int j = 0; j < tab.length; j++){ | |
63 | System.out.print(tab[i][j] + " "); | |
64 | } | |
65 | System.out.println(); | |
66 | } | |
67 | } | |
68 | ||
69 | private int sprawdzW(int w){ | |
70 | if k < 0 return kMax-1 | |
71 | if k >= kMax return 0 | |
72 | Return k | |
73 | } | |
74 | ||
75 | } |