码迷,mamicode.com
首页 > 编程语言 > 详细

算法训练 图形显示

时间:2016-03-27 19:32:33      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

  算法训练 图形显示  
时间限制:1.0s   内存限制:512.0MB
    
问题描述
  编写一个程序,首先输入一个整数,例如5,然后在屏幕上显示如下的图形(5表示行数):
  * * * * *
  * * * *
  * * *
  * *
  *
 
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=n;i>=1;i--){
            for(int j=1;j<=i;j++){
                System.out.print("* ");
            }
            System.out.println();
        }

    }

}

 

算法训练 图形显示

标签:

原文地址:http://www.cnblogs.com/watchfree/p/5326379.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!