zoukankan      html  css  js  c++  java
  • 打印正反星星 先正后反星星

    1.

    public class PrintStar {
    
    	public static void main(String[] args) {
    		
    		printAttentionStar();
    		printUpstandDownStar();
    		printUpAndDownStar();
    
    	}
    
    
    /*
    	*	
    	**
    	***
    	****
    	*****
    */
    	private static void printAttentionStar() {
    		for(int i=0; i<5; i++){
    			for(int j=0; j<=i; j++){
    				System.out.print("*");
    			}
    			System.out.println();
    		}
    		
    	}
    /*
    	*****
    	****
    	***
    	**
    	*
    */	
    	private static void printUpstandDownStar() {
    		for (int i = 0; i < 5; i++) {
    			for (int j = 5; j > i; j--) {
    				System.out.print("*");
    			}
    			System.out.println();
    		}
    		
    	}
    
    	/*
    	*
    	**
    	***
    	****
    	*****
    	*****
    	****
    	***
    	**
    	*
    */	
    
    	private static void printUpAndDownStar() {
    		int index = 0;
    		for (int i = 0; i < 10; i++) {
    			if(index < 5){
    				for (int j = 0; j <= i ; j++) {
    					System.out.print("*");
    				}
    				System.out.println();
    				index++;
    			}
    			if(index >=5){
    				for (int k = 9; k > index  ; k--) {
    					System.out.print("*");
    				}
    				System.out.println();
    				index++;
    			}
    		}
    			
    	}	
    		
    	
    }
    

      

  • 相关阅读:
    python数字
    python字符串方法
    python操作符与流程控制
    网络基础和python(二)
    网络基础和python
    Ubuntu源更新
    make和makefile介绍
    JavaScript
    redis mac安装配置
    网络编程之socket(TCP,UDP)
  • 原文地址:https://www.cnblogs.com/bravolove/p/5797698.html
Copyright © 2011-2022 走看看