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 (https://jbtalks.my/) | Powered by Discuz! X2.5 |