Guys, help with the code gray. I can not bring to mind. In response, displays 1110, 1110, 1111, 1111.
import java.io.*; public class cod { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int m; String settext = ""; int i = 4; //указываем длинну double k = Math.pow(2, i); int[][] code = new int[int k][i + 1]; code[1][i] = 0; code[2][i] = 1; for (int a = 2; a <= i; a++) { m = (int) (Math.pow(2, a)); for (int b = (int) (Math.pow(2, a - 1)) + 1; b <= m; b++) { code[b] = code[m - b + 1]; code[m - b + 1][i - a + 1] = 0; code[b][i + 1 - a] = 1; } } for (int n = 1; n <= k; n++) { for (int q = 1; q <= i; q++) { settext = Integer.toString(code [n][q]) ; System.out.print(settext); System.out.print (" "); } System.out.println(); } } }
//указываем длинну
does not help anything, if you naming the variables somehow corresponded to their purpose and the comments were not for a tick, maybe everything was much simpler, you are not taught this? - Specter