习题:打印如下图

*

**

***

****

*****




public class CeShi {


       

        public static void main(String[] args) {

               // TODO Auto-generated method stub

              

               for(int i=1;i<=5;i++)

              {

                      for(int j=1;j<=i;j++)

                     {

                           System. out.print("*" );

                           

                     }

                     System. out.println();

              }

              

       }


}



打印如下图案


   *

  ***

 *****

*******


public class Test1 {

     

     

     public static void main (String args[])

     {

           

           

            int lay=4;

            //打印行数

            for( int i=1;i<=lay;i++)

           {

                 //打出空格

                 for( int k=1;k<=lay-i;k++)

                {

                     System. out.print( " ");

                }

                 //打印*号

                 for( int j=1;j<=2*i-1;j++)

                {

                     System. out.print( "*");

                }

                

                 //打印回车

                System. out.println();

           }

    }

}


你可能感兴趣的:(java,public,result)