public static void main(String[] args) {
String [] arr = new String[]{"a","b","c","d","e","f","g"};
for (int i = 0; i <= 6; i++) {
for (int j = 0; j < i; j++)
{
System.out.print(" ");
}
for (int j = 0; j < 7 - i ; j++)
{
System.out.print(arr[j] + " ");
}
System.out.println();
}
}
打印如下:
a b c d e f g
a b c d e f
a b c d e
a b c d
a b c
a b
a