Java循环打印矩形

package practice;

import java.util.Scanner;

public class Square {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		System.out.print("请输入矩形的打印行数:");
		int lines = sc.nextInt();
		for (int i = 0; i < lines; i++) {
			if (i == 0) {
				System.out.println();
			}
			for (int j = 0; j < 8; j++) {
				System.out.print("*");
			}
			System.out.println();
		}
		
		sc.close();
		
	}

}

你可能感兴趣的:(典化成籍-Java,java,算法)