A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

/*
* * * * *
* * * *
  * * *
   * *
    *
*/
class Print6
{
        public static void main(String []args)
        {
                for(int x=1;x<=5;x++)
                {
                       
                        for(int y=0;y<x-1;y++)
                        {
                                System.out.print("-");
                        }
                        for(int z=0;z<=5-x;z++)
                        {
                               
                                System.out.print("* ");
                        }
                        System.out.println();
                }
        }
}

/*

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

*/

class Print7
{
        public static void main(String []args)
        {
                for(int x=5;x>0;x--)
                {
                       
                        for(int y=x-1;y>0;y--)
                        {
                                System.out.print("-");
                        }
                        for(int z=5;z>x-1;z--)
                        {
                               
                                System.out.print("* ");
                        }
                        System.out.println();
                }
        }
}


0 个回复

您需要登录后才可以回帖 登录 | 加入黑马