20、输入行数,打印等腰三角形

版权声明:制作人:流川枫 https://blog.csdn.net/qq_44739706/article/details/89946499
import java.util.*;

public class Xiugaicuow {

	/**
	 * 
	 */
	public static void main(String[] args) {

		System.out.println("请输入直角三角形的行数:");
		int rows = 0;// 记录三角形行数
		Scanner input = new Scanner(System.in);
		rows = input.nextInt();

		for (int i = 0; i < rows; i++) {

			for (int k = 0; k < 4 - i; k++) {
				System.out.print(" ");
			}
			for (int j = 0; j < 2 * i+ 1; j++) {

				System.out.print("*");
			}

			System.out.println();

		}

	}
}

猜你喜欢

转载自blog.csdn.net/qq_44739706/article/details/89946499
今日推荐