您的位置:首页 > 其它

for循环语句输出菱形

2015-10-04 20:44 260 查看
for(int a = 5; a > 0 ; a--){
for(int b = 1; b <= a; b++){
System.out.print(" ");
}
for(int c = 5; c >= a; c--){
System.out.print("* ");
}
System.out.println(" ");
}
for(int a = 4; a > 0 ; a--){
for(int d = 1; d > 0; d--){     //这行for循环只是为了排版用的,实际意义不大
System.out.print(" ");
}
for(int b = 4; b >= a; b--){
System.out.print(" ");
}
for(int c = 1; c <= a; c++){
System.out.print("* ");
}
System.out.println("");
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: