java类,例,从控制台输入一个正整数N,控制台上输出N个*,请教该如何编写,谢谢,最好详细一些,谢谢

2024-11-26 08:50:13
推荐回答(2个)
回答1:

import java.util.*;
public class Test_1
{
public static void main(String args[])
{
System.out.print("输入整数N:");
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for(;N>0;N--){System.out.print("*");}
}
}

回答2:

public class Test {
public static void main(String[] args) {
System.out.println("请输入数字:");
Scanner scanner = new Scanner(System.in);
int intput = scanner.nextInt();
for(int i=0;i System.out.print("*");
}
}
}