2004年8月22日 六个主要是 for 循环的小程序

类别:Java 点击:0 评论:0 推荐:

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

本文地址:http://com.8s8s.com/it/it16061.htm