网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.JAVA对JPEG图片进行处理.
.一个工作流引擎的设计概要.
.创建 JSF Web 项目和页面模板(4.
.入门:Java初学者入门要注意的基.
.Java入门:J2ee学习流程简介.
.体验 JAVA 5 的新增语言特性.
.全面研读EJB 2.0(3).
.“网络蚂蚁”的Java实现.
.经典java问题,你能答出几个?.
.比较运算符.
.设计Java程序与C语言的接口.
.软件操作界面设计须遵循的一些原.
.JBUILDERX 初体验.
.FileSystemObject 和 Scripting .
.Java中引用变量的使用.
.Excel的java处理方式.
.Java 程序中的多线程(一).
.J2ME学习札记1.
.调用Java编译器API编译Java.
.重新温习数组.

六个for循环的Java小程序源码展播

发表日期:2008-1-5



  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--,
上一篇:使用档案文件提高applet的加载速度 人气:524
下一篇:在升级到.NET1.1版之前所要考虑的四个问题 人气:574
浏览全部Java的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐