package com.zsh;

import java.util.Scanner;

public class Test08 {
  public static void main(String[] args) {
    System.out.println("请输入大于3的奇数!!");
    Scanner reader=new Scanner(System.in);
    int i;//定义行
    int j;//定义列(循环空格)
    int a;//定义列(循环*)
    int b=reader.nextInt();//取得命令行中的数据(显示行数)
    //循环前(b/2+1)行
    for(i=1;i<=b/2+1;i++){
        if(i==1){
            for(j=1;j<=(b-(2*i-1))/2;j++){
                System.out.print("  ");
            }
            System.out.println(" *");
        }
        else{
            //循环空格
            for(j=1;j<=(b-(2*i-1))/2;j++){
                System.out.print("  ");
            }
            System.out.print(" *");
            //循环*
            for(a=1;a<=2*i-3;a++){
                System.out.print("  ");
            }
            System.out.println(" *");
        }
    }
    //循环后(b/2)行
    for(i=b/2;i>=1;i--){
        if(i==1){
            //循环空格
            for(j=1;j<=(b-(2*i-1))/2;j++){
                System.out.print("  ");
            }
            System.out.println(" *");
        }
        else{
            //循环空格
            for(j=1;j<=(b-(2*i-1))/2;j++){
                System.out.print("  ");
            }
            System.out.print(" *");
            //循环*
            for(a=1;a<=2*i-3;a++){
                System.out.print("  ");
            }
            System.out.println(" *");
        }
    }
  }

}

最新文章

  1. C# 单例模式
  2. ASP.NET MVC使用Bootstrap系统(2)——使用Bootstrap CSS和HTML元素
  3. Position和anchorPoint
  4. [51单片机] EEPROM 24c02 [I2C代码封装-保存实现流水灯]
  5. 用户管理 之 Linux 用户(User)查询篇
  6. Asp.net Json 解析 与 直接用ip访问返回josn
  7. SQL查询性能分析之(not in)、(and not)、()、(!=)性能比较
  8. [Gauss]POJ3185 The Water Bowls
  9. codevs4189字典(字典树)
  10. Roads in Berland(图论)
  11. android中利用view画出一条竖线
  12. 【转】如何在CentOS/RHEL中安装基于Web的监控系统 linux-das
  13. Golang适合高并发场景的原因分析
  14. ArcGIS Pro开发Web3D应用(2)——地图分屏对比(多屏对比)思路
  15. MySQL+MGR 单主模式和多主模式的集群环境 - 部署手册 (Centos7.5)
  16. ArcGIS 中UniqueValueRenderer和SimpleRenderer的异同点
  17. python函数后面有多个括号怎么理解?
  18. 微信小程序的同步操作
  19. Edit Distance问题在两种编程范式下的求解
  20. SqlServer行转列(PIVOT),列转行(UNPIVOT)总结

热门文章

  1. ZOJ 3490 String Successor 字符串处理
  2. Chapter 6 装饰模式
  3. 通过sharedpreference两个程序共享数据
  4. 推断js中的类型:typeof / instanceof / constructor / prototype
  5. linux cmd
  6. sqlplus
  7. 第14周 项目三-OOP版电子词典
  8. 基于MapReduce的HBase开发
  9. Codeforces Round #272 (Div. 2)AK报告
  10. PHP - 接口 - 单一接口