设为首页 友情链接
在线留言 发表文章
加入收藏 广告联系

刺猬首页

| 专案技术 | 网络技术 | 图形图象 | 网络编程 | 网页设计 | 操作系统 | 服务器 | 技术白皮书 | 在线实验室 | 刺猬论坛 |
小说专版  | 数据库 | 设计赏析 | 存储频道 | 网络安全 | 私服架设 |  Solaris | 网站评估 | PC维护技巧 | 下载中心 | 博 客 |
专   题: | Linux | java | cisco | 防病毒 | 刀片 | SOA | iscsi | ASP.NET | SQL | Oracle |
您现在的位置: IT公社 IT community >> Linux专题 >> Linux 软件开发 >> 教程正文 用户登录 新用户注册
专 题 栏 目
最 新 热 门
最 新 推 荐
相 关 文 章
我的六个系统安装方法及…
  六个适合菜鸟研究的 for 循环的Java小程序         
六个适合菜鸟研究的 for 循环的Java小程序
 


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--,
             *依次类推... 所就在第二行打印了 9 个 * 。
             *接下来执行 System.out.print("\n"); 换行 。
             *然后执行第一个大循环中的 i-- ; 此时 i 就等于 8 了。
             *
             *往下 依次类推....
           */
  System.out.print("*");
  }
 
 System.out.print("\n");
 }
}
}

Linux联盟收集整理

频道声明:本频道的文章除部分特别声明禁止转载的专稿外,可以自由转载.但请务必注明出出处和原始作者 文章版权归本频道与文章作者所有.对于被频道转载文章的个人和网站,我们表示深深的谢意。

原始作者:佚名 录入时间:2007-1-2 3:18:23
信息来源:不详 投稿信箱:itqoo@126.com
教程录入:itqoo    责任编辑:itqoo 
  • 上一个教程:

  • 下一个教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    - 关于我们 - 合作伙伴 - 友情链接 - 广告刊登 - 投稿热线 - 在线留言版权声明联系方式 -
    IT公社版权所有 粤ICP备05127012号
    Copyrigh@2005-2006 itqoo.com.Inc All Rights Reserved  推荐分辨率 1024*768
    联系站长:E-Mail:itqoo@126.com     MSN:urchincc@hotmail.com    QQ:点击这里给我发消息
    特别感谢:亿太网络提供空间支持