zoukankan      html  css  js  c++  java
  • 第九章

            第九章      循环结构进阶

    英语新识:

    triangle 三角形    circle  圆圈    diamond  菱形    password  口令    row  行

    语法新知:

    while与while的循环嵌套:

    do-while 与do-while循环嵌套

    for与for循环嵌套:

    while 与for循环嵌套

    矩形的打印:

    public class RTriAngle{

      public static void main (String [] args ){

        System.out.println(" 打印矩形");

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

        for (int j=1;j<=5;j++){      

          System.out.print("*");

        }

       System.out.print("\n"); 

    }

    }

    }

    九九乘法表:

    public class RTriAngle{

      public static void main (String [] args ){

        System.out.println(" 九九乘法表:");

        for(int i=1; i<=9; i++){

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

          System.out.print(j+"*"+i+"="+j*i+" ");

        }

       System.out.print("\n"); 

    }

    }

    }

    等腰三角:

    public class RTriAngle{

      public static void main (String [] args ){

        System.out.println(" 打印等腰三角");

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

        for (int j=1;j<=5;j++){      

        System.out.print(" ");

    }

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

    System.out.print("*");

        }

       System.out.println("\n"); 

    }

    }

    }

     菱形的打印:

    int lay;

    lay=7;

    for (int m=1; m<=(lay+1)/2 ;m++){

      for (int b =1; b<=(lay+1)/2-m;b++){

    System.out.print("\n");

    }

    for(int c=1;c<=m*2-1;c++){

    System.out.print("*");

    }

    System.out.println();

    }

    for(int d =(lay+1)/2-1;d>=1;d--){

    for (int b=1; b<=(lay +1)/2-d;b++){

    System.out.print("\n");

    for(int c=(lay+1)/-d;c<=(lay+1)/2-2+d;c++){

    System.out.print("*");

    }

    System.out.println();

        }

      }

    }

     

  • 相关阅读:
    从太空到地球某个位置的轨迹录像制作 | Earth Zoom in/out Tutorial (Record Video)
    DNA replication timing数据库
    探索ENCODE数据库 | Encyclopedia of DNA Elements
    第100天: 三木板模型算法项目实战
    第99天:UDP 编程
    第98天:图像库 PIL 实例—验证码去噪
    第97天:图像库 PIL(二)
    第96天:图像库 PIL(一)
    第95天:StringIO & BytesIO
    第94天:数据分析之 pandas 初步
  • 原文地址:https://www.cnblogs.com/merrycell/p/6694150.html
Copyright © 2011-2022 走看看