用math.abs打印菱形
------解决方案--------------------
打印菱形?啥意思,楼主说明白点。是不是画一个菱形啊?
------解决方案--------------------
public class Untitled1
{
public static void main(String args[])
{
int line = Integer.parseInt(args[0]);
int n = -line;
do {
show(Math.abs(n), ' ');
show((line-Math.abs(n))*2+1, '* ');
System.out.println();
n++;
}while (n <=line);
}
public static void show(int i,char c)
{
for (int n = 0;n <i;n++)
{
System.out.print(c);
}
}
}