- import java.util.Scanner;
- public class Demo17 {
- //C.根据键盘录入的行数和列数,在控制台输出星形
- 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();
- xing(x,y);
- }
- public static void xing(int x, int y){
- for(int a = 1; a <= x; a++){
- for(int b = 1; b <= y; b++){
- System.out.print("*");
- }
- System.out.println();
- }
- }
- }
复制代码 |