黑马程序员技术交流社区
标题:
谁会输出菱形的星星?
[打印本页]
作者:
pengjk
时间:
2016-1-11 22:25
标题:
谁会输出菱形的星星?
谁会输出菱形的星星?
*
***
*****
*******
*****
***
*
作者:
黑色皮肤的马
时间:
2016-1-12 21:30
class PrintLingXing
{
public static void main(String[] args)
{
for(int x=0;x<5;x++)
{
for(int y=x;y<4;y++)
{
System.out.print(" ");
}
for(int m=0;m<=x;m++)
{
System.out.print("* ");
}
System.out.println();
}
for(int x=0;x<4;x++)
{
for(int y=0;y<=x;y++)
{
System.out.print(" ");
}
for(int m=x;m<4;m++)
{
System.out.print("* ");
}
System.out.println();
}
}
}
复制代码
作者:
wuzeshui
时间:
2016-1-12 21:49
class practise3_lingxing {
public static void main(String[] args) {
for (int i = 0; i < 19; i++) {
for (int j = 0; j < 19; j++) {
if (j >= Math.abs(9 - i) && j < 19 - Math.abs(9 - i))
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
//简单又好看,希望对你有帮助
作者:
n_Nie1991
时间:
2016-1-12 22:22
要定义两个for 循环
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2