java算法题

输出
*
**
***
****
*****
****
***
**
*

public class PrintAsterisk {

	public static void main(String[] args) {
		
		print(1);
	}
	public static void printAsteriskInline(int number){
		 for (int i = 0; i <number; i++) {
			System.out.print("*");
		}
		 System.out.println();
	}
	
	public static void print(int number){
		printAsteriskInline(number);
		if (number<5) {
			print(number+1);
			printAsteriskInline(number);
		}
	}
}

你可能感兴趣的:(java算法题)