谢谢你们问题已解~~
|
898| 2
|
问题已解~~ |
Question 1
Write an application that displays the following pattern as output. by using for loops.
You shall use the output statements that print a single asterisk (*), a single space or a single newline character. Maximum your use of repetition and minimize the number of output statement.
*********
*******
*****
***
*
***
*****
*******
*********
这是我的code:
int i, j;
for (i = 4; i > 0; i--) {
for (j = i; j < 4; j++) {
System.out.print(" ");
}
for (j = i; j > 0; j--) {
System.out.print("*");
}
for (j = i; j > 0; j--) {
System.out.print("*");
}
System.out.println();
}
}}
My Output:
********
******
****
**
seongchog 发表于 2011-9-16 03:33 PM
JBTALKS.CC |联系我们 |隐私政策 |Share
GMT+8, 2026-1-1 07:21 AM , Processed in 0.091575 second(s), 21 queries .
Powered by Discuz! X2.5 © 2001-2012 Comsenz Inc.
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
Dedicated Server powered by iCore Technology Sdn. Bhd.