JAVA常见算法题(二十)
2024-08-28 14:03:19
package com.xiaowu.demo; /**
*
*
打印出如下图案(菱形) *
*
*
* @author WQ
*
*/
public class Demo20 {
public static void main(String[] args) {
display(5);
} public static void display(int h) {
for (int i = 0; i < (h + 1) / 2; i++) {
for (int j = 0; j < h / 2 - i; j++) {
System.out.print(" ");
}
for (int k = 1; k < (i + 1) * 2; k++) {
System.out.print("*");
}
System.out.println();
}
for (int i = 1; i <= h / 2; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(" ");
}
for (int j = 0; j < h - 2 * i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
最新文章
- HTTP权威协议笔记-7.缓存
- UWP入门教程1——UWP的前世今生
- spring mvc WebArgumentResolver不生效
- MIT 6.828 JOS学习笔记0. 写在前面的话
- Swift3.0语言教程替换子字符串
- 小心!#define max(a,b) a>;b?a:b
- c# 实现文件批量压缩
- 模板方法模式(TemplateMethod)
- iOS WebView的用法
- leetcode-004 insertion sort list
- [转]JAVA自动装箱和拆箱
- ojdbc6下载地址
- win7 win10开启网络访问(网络访问 无法访问 网络访问需要输入密码 等问题处理)
- Coroutines declared with async/await syntax is the preferred way of writing asyncio applications. For example, the following snippet of code (requires Python 3.7+) prints “hello”, waits 1 second, and
- 使用InstallAnywhere7.1制作Java exe程序安装包
- sap 对dynamic query parameters 设置条件。
- select标签和多行文本标签
- Architecture And Framework
- 第一个python程序(2)
- elasticsearch中ik词库配置远程热加载