一·二重
(1)输出结果如下:
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 7
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
public class Test { public static void main(String[] args){ int i,j,; for(i = 1;i <= 9;i++){ for(j = 1;j <= i;j++){ System.out.print(j); } System.out.println(); } } }
(2)输出结果如下:
9 8 7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
7 6 5 4 3 2 1
6 5 4 3 2 1
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
(3)
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
public class Test { public static void main(String[] args){ int i,j,m,n; for(i = 1;i <= 6;i++){ for(j = 1;j + i <= 7;j++){ System.out.print(j); } System.out.println(); } } }
二·三重
public class He { public static void main(String[] args){ int i,j,m; for(i = 1;i <= 6;i++){ for(j = 1;j + i <= 6;j++){ System.out.print(" "); } for(m = i;m > 0;m--){ System.out.print(m); } System.out.println(" "); } } }
时间: 2024-10-29 00:08:06