I've been trying to write a program for the last 3 hours with no success. What probably should seem easy to most I'm having difficulty with. I have to print two separate patterns on the same program.
I've selected the following two:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6
X 1 2 3 4 5
X X 1 2 3 4
X X X 1 2 3
X X X X 1 2
X X X X X 1
Imagine the X's are not there on the one above. Every time I previewed the post it showed it a different way without the X's.
This is the two patterns stacked up, any ideas?
Here's what I have so far and it gets me to the first line of pattern 2:
public class TwoPatterns {
public static void main(String[] args) {
for (int a = 1; a <= 6; a++) {
for (int b = 1; b <= a; b++) {
System.out.printf("%-4d", b);
}
System.out.println();
}
for (int c = 6; c >= 6; c--) {
for (int d = 1; d <= c; d++) {
System.out.printf("%-4d", d);
}
System.out.println();
}
}
}
any help would be so appreciated!