爱心Java for循环实现
2024-08-31 10:38:15
public class x {
public static void main(String[] args) {
for (int i = 0, k = 0; i < 14; i++) {
if (i < 3) {
for (int j = 0; j < 5 - 2 * i; j++) {
System.out.print(" ");
}
if (i == 2) {
for (int j = 0; j < 6 + 4 * i - 1; j++) {
System.out.print("*");
}
for (int j = 0; j < 7 - 4 * i + 2; j++) {
System.out.print(" ");
}
for (int j = 0; j < 6 + 4 * i - 1; j++) {
System.out.print("*");
}
} else {
for (int j = 0; j < 6 + 4 * i; j++) {
System.out.print("*");
}
for (int j = 0; j < 7 - 4 * i; j++) {
System.out.print(" ");
}
for (int j = 0; j < 6 + 4 * i; j++) {
System.out.print("*");
}
}
} else if (i < 6) {
for (int j = 0; j < 29; j++) {
System.out.print("*");
}
} else {
if (i == 13) {
for (int j = 0; j < 2 * (i - 6); j++) {
System.out.print(" ");
}
System.out.print("*");
} else {
for (int j = 0; j < 2 * (i - 6) + 1; j++) {
System.out.print(" ");
}
for (int j = 1; j < 28 - 4 * k; j++) {
System.out.print("*");
}
k++;
}
}
System.out.println();
}
}
}
最新文章
- ADSL自动更换IP地址源代码
- TimeUnit 使用
- .NET两种常见上传下载文件方法
- Arch 常用工具
- 网页、php脚本的编码问题
- ENode框架Conference案例转载
- 浅谈对SpringMVC的认识
- solr-搭建与使用过程中问题总结-链接
- HandsonTable日期控件的汉化
- Shell 全局变量、环境变量和局部变量
- XMPP技术之Smack库的自定义消息扩展
- Java8新特性 重复注解与类型注解
- Codeforces Round #514 (Div. 2) B - Forgery
- Android 创建单独的服务运行在后台(无界面)
- xxx.app已损坏,打不开.你应该将它移到废纸篓-已解决
- [LeetCode] 129. Sum Root to Leaf Numbers_Medium tag: DFS
- json模块&;xml
- out, ref 和 params 的区别和用法
- 安装Thinkphp5
- zookeeper+kafka集群的安装部署