1.
1 import java.io.*; 2 public class Practice { 3 public static void main(String[] args){ 4 for(int i=0; i<5; ++i){ 5 for(int j=0; j<i+1; ++j){ 6 System.out.print(‘*‘); 7 } 8 System.out.println(); 9 } 10 } 11 } 12 * 13 ** 14 *** 15 **** 16 *****
2.
1 import java.io.*; 2 public class Practice { 3 public static void main(String[] args){ 4 for(int i=1; i<=5; ++i){ 5 for(int j=1; j<=5-i; ++j){ 6 System.out.print(‘ ‘); 7 } 8 for(int k=0; k<i; ++k){ 9 System.out.print(‘*‘); 10 } 11 System.out.println(); 12 } 13 } 14 } 15 * 16 ** 17 *** 18 **** 19 *****
3.
1 import java.io.*; 2 public class Practice { 3 public static void main(String[] args){ 4 for(int i=1; i<=5; ++i){ 5 for(int j=1; j<=(9-((i-1)*2+1))/2; ++j){ 6 System.out.print(‘ ‘); 7 } 8 for(int k=1; k<=(i-1)*2+1; ++k){ 9 System.out.print(‘*‘); 10 } 11 System.out.println(); 12 } 13 } 14 } 15 16 * 17 *** 18 ***** 19 ******* 20 *********
时间: 2024-10-23 17:03:05