好长哦= =有答案简短点吗??
class Test
{
public static void main(String[] args)
{
for (int x=0;x<5 ;x++ )
{
print_1('-',x+1,5);
print_1('x',0,1);
if(x==0)
print_3();
else
{
print_2(' ');
for(int y=1;y<x;y++)
{
print_4();
}
}
for (int y=0;y<1 ;y++ )
{
if(x==0)
print_2(' ');
else
print_2('x');
}
print_2('\n');
}
for (int x=0;x<4 ;x++ )
{
for (int y=0;y<=x ;y++ )
{
print_2('-');
}
print_1('x',0,1);
if(x==4)
print_3();
else
{
print_2(' ');
for (int y=2;y>x ;y-- )
{
print_4( );
}
}
for (int y=0;y<1 ;y++ )
{
if(x==3)
print_2(' ');
else
print_2('x');
}
print_2('\n');
}
}
public static void print_1(char a,int b,int c)
{
for(int y=b;y<c;y++)
System.out.print(a);
}
public static void print_2(char a)
{
System.out.print(a);
}
public static void print_3()
{
System.out.print("");
}
public static void print_4()
{
System.out.print(" ");
}
} |