- class ThreeAngle {
- public static void main(String[] args) {
- for (int i=1;i<=7 ;i++ ){
- for (int j=6;j>=i ;j-- ){
- System.out.print(" ");
- }
- for (int k=i;k>=1 ;k-- ){
- System.out.print(" "+k);
- }
- for (int k=1;k<=i-1 ;k++ ){
- System.out.print(" "+(k+1));
- }
- System.out.println();
- }
- }
- }
复制代码
打印效果:
1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5
6 5 4 3 2 1 2 3 4 5 6
7 6 5 4 3 2 1 2 3 4 5 6 7 |
|