50,530
社区成员
发帖
与我相关
我的任务
分享
*
**
***
****
//调用
int n = 4;
show(n,n);
运行结果:
*
* *
* * *
* * * *
请按任意键继续. . .
public class Test1 {
public static void main(String[] args) {
System.out.println("打印行数");
int n=new Scanner(System.in).nextInt();
setV(n);
}
static int a=1;
private static Object setV(int n) {
if(n<0)return 0;
for(int i=1;i<a;i++){
System.out.print("*");
}
System.out.println();
a++;
return setV(n-1);
}
}