for循环练习一

1.

打印

*************
*************
*************
*************

for(int j=1;j<=4;j++)//判断换行
{
for(int i=0;i<=14;i++)//循环输入
{
System.out.print("*");
}
System.out.println();
}    

2.打印

*
**
***
****
*****

for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)    
{
    System.out.print("*");
}
System.out.println();
}

 3.

打印

*****
****
***
**
*
n行(键盘输入)

public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
for(int i=1;i<=n;i++)
{
    for(int j=n;j>=n-i+1;j--)
    {
        System.out.print("*");
    }

System.out.println();
}
原文地址:https://www.cnblogs.com/foreverstudent/p/3051268.html