Desenvolvi uma matriz em char com n colunas e n linhas com caracteres de A á Z, e ao atingir Z pode-se inciar com A de novo. Mas queria modelar minha matriz em formato de ‘Z’ .
Como está saindo:
ABCDEFGHIJKLMNO
PQRSTUVWXYZABCD
EFGHIJKLMNOPQRS
TUVWXYZABCDEFGH
IJKLMNOPQRSTUVW
XYZABCDEFGHIJKL
MNOPQRSTUVWXYZA
BCDEFGHIJKLMNOP
QRSTUVWXYZABCDE
E como eu queria que fosse:
ABCDEFGHI
J
K
L
M
N
O
P
Q
R
STUVWXYZAB
como fazer?
Este é meu Codigo:
package PorZLine;
import java.util.Scanner;
public class ProgramaZ {
char letraAtual;
public static void main(String[] args) {
char lol = 'A';
Scanner imprint = new Scanner(System.in);
System.out.print("Digite a letra: ");
int n = imprint.nextInt();
char matriz[][] = new char[n][n];
for (int x = 0; x < n; x++) {
for (int y = 0; y < n; y++) {
matriz[x][y] = lol;
lol++;
System.out.print(matriz[x][y]);
if (lol == '[') {
lol = 'A';
if (x == 0|| x == n - 1 ||y == n - 1000 - x) {
System.out.println();
}
}
}
System.out.println();
}
}
}