zoukankan      html  css  js  c++  java
  • 20130330java基础学习笔记语句_for循环嵌套练习2

    class ForForTest
    {
        public static void main(String[] args)
        {
            /*用for循环做出以下图:
            * * * * *
             * * * *
              * * *
               * *
                *
            */
            for(int x=1; x<=5; x++)
            {
                for(int y=1; y<x; y++)
                {
                    System.out.print(" ");
                }
                for(int z=x; z<=5; z++)
                {
                    System.out.print("*");
                }
                System.out.println();
            }
        }
    }

    //方法二:

    public class Test2
    {
        public static void main(String[] args)
        {
            String s = "";
            String x ="";
            for (int i = 5; i > 0; i--)
            {
                x ="";
                System.out.print(s);
                for (int j = 0; j < i; j++)
                {
                    x += "* ";
                }
                s += " ";
                System.out.print(x);
                System.out.println();
            }
        }
    }

  • 相关阅读:
    spark 程序 TopN FileSort SecondarySort 的出错解决办法
    预报温度和体感温度不是一回事
    搜索引擎 搜索技巧
    scrapy 爬虫框架
    scala-sbt
    英语削笔机
    php 一句话木马
    [CS充实之路] CS50 WEEK 1
    UBUNTU 16.04 编译 OPENJDK8
    使用logrotate分割Tomcat的catalina日志
  • 原文地址:https://www.cnblogs.com/lisu/p/2990693.html
Copyright © 2011-2022 走看看