I want to print the followin matrix using for loops:
1 2 3 4 5 6
2 3 4 5 6 1
3 4 5 6 1 2
4 5 6 1 2 3
5 6 1 2 3 4
6 1 2 3 4 5
I use:
public static void main ( String [ ] args ) {
for(int w = 1; w <= 6; w++){
System.out.println("");
for(int p = w; p <= 6; p++){
System.out.print(p + "");
}
}
}
But it prints:
1 2 3 4 5 6
2 3 4 5 6
3 4 5 6
4 5 6
5 6
6