A job title (a star circulation problems)

Category: Java SE
 
s110300744
2012-09-28 09:36:40

Sponsored Links
The following four separate triangles printed side by side together
************* *
**************
**************
*** ***********
***** *********
******* *******
with the least for loop to write

Sponsored Links

zxy999521
2012-09-28 09:39:52
for (i = 1; i < = 6; i + +) {
for (j = 1; j <= i; j + +)
print ("*");
for (j = 6; j> = 1 ; j -)
print ("");
for (j = 6; j> = 1; j -)
print ("*") ;
for (j = 1; j <= i; j +)
print ("");
for (j = 6; j> = 1; j - )
print ("*");
for (j = 6; j> = 1; j -)
print ("");
.......
to work, write it below. Can be optimized.
vincent3434
2012-09-28 09:51:11
for (int j = 0; j <7; j + +)
{for (int i = 6-j; i <7; i + +)
{
System.out.print ("*");
}
for (int ; i = j; i <7; i + +)
{
System.out.print ("");
}
for (int i = j; i <7; i + +)
{
System.out.print ( "*");
}
for (int i = 0; i <j * 2 +1; i + +)
{
; System.out.print ("");
}
for (int i = j; i <7; i + +)
{
System.out.print ("*");
}
for (int i = j; i <7; i + +)
{
System.out.print ("");
}
for (int i = 6-j; i <7; i + +)
; {
System.out.print ("*");
}

System.out.println ( "");
}
xuelang2000
2012-09-28 10:10:53

int index = 1;
int len ​​= 6;
int i;
for (index = 1; index <= 6; index + +)
{

for (i = 1; i <= index; i + +)
; System.out.print ("*");
for (i = 1; i <= len-index ; i + +)
System.out.print ("");
; System.out.print ("");
/ / ------------- ------------------
for (i = 1; i <= len -index +1; i + +)
System.out.print ("*");
for (i = 1; i <= index-1; i + +)
System . out.print ("");
System.out.print ("");
; / / -------------------------------
for (i = 1; i <= index-1; i + +)
; System.out.print ("");
for (i = 1; i <= len-index + 1; i + +)
System.out.print ("*");
; System.out.print ("");
/ / --------- ----------------------
for (i = 1; i <= len-index; i + +)
System.out.print ("");
; for (i = 1; i <= index; i + +)
System.out.print ("*");
System.out.println ();
I was a novice , initiate
zhangya_976858950
2012-09-28 10:19:35
for (int i = 0; i <6; i + +) {
printstart1 (i +1);
; printstart1 (6-i);
printstart2 (6-i);
System.out.print (" ; ");
printstart2 (i);
}
private void printstart1 (int j) {
for (i = 0; i <7; i + +) {
if (i <j)
; System.out.print ("*");
else
; System.out.print ("");
}
}
private void printstart2 (int ; j) {
for (i = 0; i <6; i + +) {
if (i> j)
System.out.print ("*");
else
System.out.print ("");
}
}
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.