黑马程序员技术交流社区
标题:
关于for 打印各种 星星图形(比较简单就没写注释)
[打印本页]
作者:
吃肉的小绵羊
时间:
2016-3-23 19:21
标题:
关于for 打印各种 星星图形(比较简单就没写注释)
*****
*****
*****
*****
class TuXing1
{
public static void main(String[] args)
{
for(int x=0;x <5 ;x++ )
{
for(int y=0;y<5;y++)
{
System.out.print("* ");
}
System.out.println(" ");
}
}
}
复制代码
*
**
***
****
*****
lass TuXing2
{
public static void main(String[] args)
{
for(int x=0;x<=5;x++)
{
for(int y=0;y<x;y++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
复制代码
******
*****
****
***
**
*
class TuXing3
{
public static void main(String[] args)
{
for(int x=0;x<=5;x++)
{
for(int y=x;y<=5;y++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
复制代码
*
**
***
****
*****
class TuXing4
{
public static void main(String[] args)
{
for(int x=1;x<=5;x++)
{
for(int y=1;y<=5-x;y++)
{
System.out.print(" ");
}
for(int z=1;z<=x;z++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
复制代码
*****
****
***
**
*
class TuXing5
{
public static void main(String[] args)
{
for(int x=1;x<=5;x++)
{
for(int y=0;y<x-1;y++)
{
System.out.print(" ");
}
for(int z=0;z<6-x;z++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
复制代码
*
***
*****
*******
*********
************
class TuXing6
{
public static void main(String[] args)
{
for(int x=0;x<6;x++)
{
for(int y=1;y<6-x;y++)
{
System.out.print(" ");
}
for(int z=0;z<2*x+1;z++)
{
System.out.print("*");
}
for(int n=0;n<5;n++)
{
System.out.print(" ");
}
System.out.println(" ");
}
}
}
复制代码
*******
*****
***
*
class TuXing7
{
public static void main(String[] args)
{
for(int x=0;x<5;x++)
{
for(int y=0;y<x;y++)
{
System.out.print(" ");
}
for(int z=0;z<7-2*x;z++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
复制代码
*
***
*****
*******
*********
***********
*********
*******
*****
***
*
class TuXing8
{
public static void main(String[] args)
{
for(int x=0;x<=5;x++)
{
for(int y=0;y<5-x;y++)
{
System.out.print(" ");
}
for(int z=0;z<2*x+1;z++)
{
System.out.print("*");
}
System.out.println(" ");
}
for(int x=0;x<5;x++)
{
for(int y=0;y<=x;y++)
{
System.out.print(" ");
}
for(int z=0;z<9-2*x;z++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
复制代码
******
******
******
******
class TuXing9
{
public static void main(String[] args)
{
for(int x=0;x<4;x++)
{
for(int y=0;y<4-x;y++)
{
System.out.print(" ");
}
for(int z=0;z<6;z++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
复制代码
*****
*******
*********
***********
*************
class TuXing10
{
public static void main(String[] args)
{
for(int x=0;x<5;x++)
{
for(int y=0;y<4-x;y++)
{
System.out.print(" ");
}
for(int z=0;z<5+2*x;z++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
}
复制代码
作者:
Yoyoqiu
时间:
2016-3-23 20:09
刚好看到九九乘法表 谢谢楼主了
作者:
kaifei2018
时间:
2016-3-23 21:19
黑马程序员入驻传智郑州校区
吃住行全览,UI设计学科首期开设!
作者:
追梦de蜗牛2016
时间:
2016-3-23 22:22
顶一下,不错!
作者:
吃肉的小绵羊
时间:
2016-3-24 16:21
Yoyoqiu 发表于 2016-3-23 20:09
刚好看到九九乘法表 谢谢楼主了
加油
作者:
youngsave
时间:
2016-3-24 16:54
哈哈这个好
作者:
丿若恋灬如初
时间:
2016-3-24 17:07
for循环应用,值得学习
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2