我需要画一个数字的钻石,例如与9高度:图纸数字钻石
1
222
33333
4444444
555555555
4444444
33333
222
1
我写的代码,我设法得到相同的钻石,但星星。我想要这些数字。我怎样才能做到这一点?以下是我迄今所做的:
for (int i = 1; i < 10; i += 2) {
for (int j = 0; j < 9 - i/2; j++)
System.out.print(" ");
for (int j = 0; j < i; j++)
System.out.print("a");
System.out.print("\n");
}
for (int i = 7; i > 0; i -= 2) {
for (int j = 0; j < 9 - i/2; j++)
System.out.print(" ");
for (int j = 0; j < i; j++)
System.out.print("b");
System.out.print("\n");
}
用'i'更换'stars'或'j'我要去承担其用'j' – 3kings
http://codegolf.stackexchange.com/questions/8696/print-this-diamond - 不是你想要的,但一些有趣的方法... –