标题: 打印m行n列的星形矩形,这个你练过码? [打印本页] 作者: 刘文秀 时间: 2016-7-27 22:34 标题: 打印m行n列的星形矩形,这个你练过码? public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入行数:");
int x = sc.nextInt();
System.out.println("请输入列数:");
int y = sc.nextInt();
print(x,y);
}
public static void print(int a,int b ) {
for (int i = 1;i <= a ;i++ ) {
for (int j = 1;j <= b ;j++ ) {
System.out.print("*");
}
System.out.println();
}
}