日期:2014-05-20 浏览次数:20817 次
import java.util.*;
class temp
{
public static void main(String []args)
{
Scanner sc=new Scanner(System.in);
int count=sc.nextInt();
int b=1;
for (int i=1; i<=count; i++)
{
if (!(i%2==0))
{
for (int j=count/2+1;j>b;j--)//j=count/2+1
{
System.out.print(" ");
}
}
for (int y=1; y<=i; y++)
{
if (!(i%2==0))
{
System.out.print("*");
}
}
if (!(i%2==0))
{
System.out.println();
b++;
}
}
int a=1;
for (int i=count-2; i>0; i--)
{
if (!(i%2==0))
{
for (int j=0; j<a; j++)
{
System.out.print(" ");
}
}
for (int y=i; y>0; y--)
{
if (!(i%2==0))
{
System.out.print("*");
}
}
if (!(i%2==0))
{
System.out.println();
a++;
}
}
}
}
private int len=3;
public void printRhombus(){
if(len%2==0) --len;
for (int i =len/2; i >=-len/2; i--) {
System.out.print(repeatStr(" ", Math.abs(i)));
System.out.print(repeatStr("*", len-Math.abs(i)*2));
System.out.println(repeatStr(" ", Math.abs(i)));
}
}
public String repeatStr(String str,int repeatCount){
if(str==null
------解决方案--------------------
str.length()==0
------解决方案--------------------