@java blue bridge group B Exercise training algorithm cup piece (241) ALGO-101: Graphic Display

Keywords: loop

topic:

Description of the problem
  to write a program, a first input integer, e.g. 5, and shows the following pattern (the number of rows 5) on the screen:
  * * * * *
  * * * *
  * * *
  * *
  *

Code:

public class Main {
    public static void main(String[] args) {
    	java.util.Scanner s=new java.util.Scanner(System.in);
    	int a=s.nextInt();
    	for(int i=a;i>0;i--){
    		for(int j=i;j>0;j--){
    			System.out.print("*"+" ");
    		}
    		System.out.println();
    	}
    }
}

Published 29 original articles · won praise 1 · views 1087

Guess you like

Origin blog.csdn.net/DAurora/article/details/105254642