使用java中for循环,循环打印出五角星--
//5.0 输出五角星
int touHigh = 6;
int jianHigh = 25 ;
int kuang =50;
for (int i=1;i<=touHigh+jianHigh;i++){
for(int j =1;j<=kuang;j++){
//上三角
if (i<=touHigh) {
if(j>=(kuang/2+1)+1-i && j<=(kuang/2+1)-1+i){
System.out.print("*");
}else{
System.out.print("-");
}
}
//上三角一下部分
if (i>touHigh&&i<=jianHigh){
if(j>=(kuang/2+1)+1-i&&j<=kuang-3*(i-touHigh)){System.out.print("*");
}
else if(j<=(kuang/2+1)-1+i&&j>=0+3*(i-touHigh)){System.out.print("*");
}
else {System.out.print("-");
}
}
}
System.out.println("");
}
使用java中for循环,循环打印出五角星--的更多相关文章
- 编写Java程序,使用循环结构打印出九九乘法表
编写Java程序,使用循环结构打印出九九乘法表 效果如下: 实现代码: public class Multiplication99 { public static void main(String[] ...
- Java中的do-while循环——通过示例学习Java编程(11)
作者:CHAITANYA SINGH 来源:https://www.koofun.com/pro/kfpostsdetail?kfpostsid=22&cid=0 在上一篇教程中,我们讨论了w ...
- Java中的for循环——通过示例学习Java编程(9)
作者:CHAITANYA SINGH 来源:https://www.koofun.com/pro/kfpostsdetail?kfpostsid=21 循环用于反复执行同一组语句,直到满足特定条件 ...
- [转帖]java中的for循环
java中的for循环 https://baijiahao.baidu.com/s?id=1621622990642364099&wfr=spider&for=pc 发现自己连 for ...
- Java中使用二重循环打印沙漏图形
1.首先判断外层,A .B.C.D都符合条件 2.那么再看内层 A :int i=0;i<5;i++ 当i=1时;带入到第二个内层循环中 int j=0;j<Math.abs(i)*2+1 ...
- java中使用二重循环打印图形
如图所示:打印沙漏图形 1:因为外层循环控制图形行数,所以首先判断这四个选项能否循环五次 2:以上四个循环的表达式都能循环五次,我们从内层循环入手. A:int i=0;i<5;i++ 当i=1 ...
- JAVA中的for-each循环与迭代
在学习java中的collection时注意到,collection层次的根接口Collection实现了Iterable<T>接口(位于java.lang包中),实现这个接口允许对象成为 ...
- Java中list在循环中删除元素的坑
JAVA中循环遍历list有三种方式for循环.增强for循环(也就是常说的foreach循环).iterator遍历. 1.for循环遍历list for(int i=0;i<list.siz ...
- 关于java中的一些循环
1:switch语句 (1)格式: switch(表达式) { case 值1: 语句体1; break; case 值2: 语句体2; break; ... default: 语句体n+1; bre ...
随机推荐
- 删除.svn 文件
新建一个delete_svn.bat文件 @echo on color 2f mode con: cols= lines= @REM @echo 正在清理SVN文件,请稍候...... @rem 循环 ...
- centos禁止 You have new mail in /var/spool/mail/root提示
在/etc/profile 增加unset MAILCHECK
- EmEditor的正则表达式
前提是 "使用正则表达式"的复选框打上勾. 1 查找<>之间的字符串: ".*?"2 查找双引号之间的字符串: ".*?" ...
- 323. Number of Connected Components in an Undirected Graph按照线段添加的并查集
[抄题]: Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of n ...
- opennebula 补丁制作与补丁升级
参考文章:http://www.cnblogs.com/itech/archive/2009/08/19/1549729.htmlhttp://www.ibm.com/developerworks/c ...
- 区块链相关在线加解密工具(非对称加密/hash)
https://cse.buffalo.edu/blockchain/tools.html https://cse.buffalo.edu/blockchain/encryption.html 由纽约 ...
- Warning: Data truncated for column 'xxxx' at row 1
The problem was that I changed the column's length only in the program.I had to do either change the ...
- msdn 硬盘
https://msdn.microsoft.com/library/windows/hardware/ff566204 Returns the ATA-2 identify data, the Se ...
- Laravel 5.4 实现无限级分类
最近在工作中遇到一个需求,是要在laravel 5.4中实现无限级分类,但发现网上这个的资料较少,所以只能自己来实现了,下面这篇文章主要给大家介绍了关于在laravel 5.4中实现无限级分类的方法示 ...
- 10个实用的UX设计作品推销小窍门
以下内容由Mockplus(摹客)团队翻译整理,仅供学习交流,Mockplus是更快更简单的原型设计工具. 众所周知,产品用户体验很重要,即使是Google也知道这一点.但是,当真正涉及到UX 设计销 ...