Help me to write the following: 1 121 12321 1234321 123454321
Help me to write the following
1
121
12321
1234321
123454321
thanks
class Pyramid{
public static void main(String[] args){
int x = 5;
for(int i = 1; i <= x; i++) {
for(int j = 1; j <= x - i; j++)
System.out.print(" ");
for (int k = 1; k <=i; k++)
System.out.print((k>= 10) ?+ k : " " + k);
for (int k = i-1; k >= 1; k--)
System.out.print((k >=10) ?+ k : " " + k);
System.out.println();
}
}
}
i'm sorry if that more than 10 the pyramid become the right side... help me... thanks..
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 6 5 4 3 2 1
1 2 3 4 5 6 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 910 9 8 7 6 5 4 3 2 1