国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

六個for循環的Java小程序源碼展播

2019-11-18 11:13:25
字體:
來源:轉載
供稿:網友

  1、
  /*
   * Created on 2004-8-22
   *
   * TODO To change the template for this generated file go to
   * Window - PReferences - java - Code Style - Code Templates
   */
  
  /**
   * @author diyer6
   *
   * TODO To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  /*
   此圖是運行結果:
  **********
   *********
    ********
     *******
      ******
       *****
        ****
         ***
          **
           *
  */
  public class XingHaoOne {
   public static void main(String[] args) {
   for(int i=10;i>0;i--){
    for (int j=0; j < 10-i; j++) {
  
           System.out.print(" ");
          }
  
       for(int o=i;o>0;o--){
         System.out.print("*");
       }
    System.out.print("/n");
      }
    }
  
  2、
  /*
   * Created on 2004-8-22
   *
   * TODO To change the template for this generated file go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  
  /**
   * @author diyer6
   *
   * TODO To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  /*
   此圖是打印結果:
  
  *
  **
  ***
  ****
  *****
  ******
  *******
  ********
  *********
  **********
  
   */
  public class XingHaoTwo {
  
   public static void main(String[] args) {
   for(int i=10;i>0;i--){ 
       for(int n=i;n<11;n++){ 
  
         System.out.print("*");
        }
    System.out.print("/n");
      }
    }
  }
  
  3、
  /*
   * Created on 2004-8-22
   *
   * TODO To change the template for this generated file go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  
  /**
   * @author diyer6
   *
   * TODO To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  /*
   此圖是運行結果:
  
  **********
  *********
  ********
  *******
  ******
  *****
  ****
  ***
  **
  *
  
   */
  public class XingHaoThree {
  
   public static void main(String[] args) {
   for(int i=10;i>0;i--)
   {
    for(int j=0;j  System.out.print("*");
   System.out.print("/n");
   }
   }
  }
  
  4、
  /*
   * Created on 2004-8-22
   *
   * TODO To change the template for this generated file go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  
  /**
   * @author diyer6
   *
   * TODO To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  /*
  此圖是打印結果:
  
           *
          **
         ***
        ****
       *****
      ******
     *******
    ********
   *********
  **********
  
   */
  public class XingHaoFour {
  
   public static void main(String[] args) {
   for(int i=10;i>0;i--)
   {
    for(int j=i;j>1;j--){
      System.out.print(" ");}
   
    for(int n=i;n<11;n++){
         System.out.print("*");
       }
   
   System.out.print("/n");
   }
  
   }
  
  }
  
  5、
  /*
   * Created on 2004-8-22
   *
   * TODO To change the template for this generated file go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  
  /**
   * @author diyer6
   *
   * TODO To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  /*
  此圖是運行結果:
  
  ***********
  ***********
  ***********
  ***********
  ***********
  ***********
  ***********
  ***********
  ***********
  ***********
  
  */
  public class XingHaoJuXing {
  
   public static void main(String[] args) {
   
   for(int i=10;i>0;i--){
   
    for(int n=0;n  System.out.print("*");
    }
   
    for(int j=i;j<11;j++){
    System.out.print("*");
    }
    System.out.print("/n");
    
   }
   }
  }
  
  6、
  /*
   * Created on 2004-8-22
   *
   * TODO To change the template for this generated file go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  
  /**
   * @author diyer6
   *
   * TODO To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  /*
  此圖是打印結果:
  
  **********
  **********
  **********
  **********
  **********
  **********
  **********
  **********
  **********
  **********
  
   */
  public class Shishi {
  
   public static void main(String[] args) {
   for(int i=10;i>0;i--){
    for(int f=0;f<10;f++){
    System.out.print("*");}
  
    System.out.print("/n");
  
     }
   }
  }
  
  再來個帶 注釋 的 :
  
  /*
   * Created on 2004-8-22
   *
   * TODO To change the template for this generated file go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  
  /**
   * @author diyer6
   *
   * TODO To change the template for this generated type comment go to
   * Window - Preferences - Java - Code Style - Code Templates
   */
  /*
  此圖是打印結果:
  
  0**********
  00*********
  000********
  0000*******
  00000******
  000000*****
  0000000****
  00000000***
  000000000**
  0000000000*
  
   */
  public class Zaishi {
  
   public static void main(String[] args) {
   for(int i=10;i>0;i--){
    for(int j=i;j<11;j++){ //j=10;j<11;循環一次,打印一個 0 ,在執行 j++ ,
                    //此時j=11;i<11;為false,所以在第一行只打印了一個 0 。
    System.out.print("0");}
    for(int n=i;n>0;n--){ /*n=10;n>0;循環一次,打印一個 * ,在執行n--,
               *此時n=9;n>0;再循環一次,再打印一個 * ,在執行n--,
               *此時n=8;n>0;再循環一次,再打印一個 * ,在執行n--,
               *依次類推... 所就在第一行打印了10個 * 。
               *接下來執行 System.out.print("/n"); 換行 。
               *然后執行第一個大循環中的 i-- ; 此時 i 就等于 9 了。
               *
               *這時 第一個小循環 中:(j=i 從 i=9 開始循環)
               *j=9;j<11;循環兩次,所以在第二行只打印 2 個 0 。
               *這時 第二個小循環 中:(n=i 從 i=9 開始循環)
               *n=9;n>0;循環一次,打印一個 * ,在執行n--,
               *此時n=8;n>0;再循環一次,再打印一個 * ,在執行n--,

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 公主岭市| 西城区| 高邑县| 儋州市| 襄汾县| 平谷区| 山东省| 进贤县| 平南县| 泾川县| 专栏| 泾源县| 白玉县| 鹤庆县| 阿坝县| 老河口市| 衡东县| 湟源县| 从化市| 腾冲县| 渑池县| 丹棱县| 修水县| 武乡县| 博湖县| 营口市| 北碚区| 板桥市| 江山市| 资兴市| 江孜县| 巴青县| 贵溪市| 阿勒泰市| 淮北市| 开平市| 鲁甸县| 体育| 沾化县| 凤山市| 门头沟区|