用math.abs打印菱形!!请指教

chilina 2007-01-16 02:21:21
用math.abs打印菱形
...全文
153 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mymyhope 2007-01-16
  • 打赏
  • 举报
回复
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);
}
}
}
chilina 2007-01-16
  • 打赏
  • 举报
回复
不是的,是这样的如下图:
*
* * *
* * * * *
* * *
*
闭门车 2007-01-16
  • 打赏
  • 举报
回复
打印菱形?啥意思,楼主说明白点。是不是画一个菱形啊?

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧