怎么用Eclipse实现以下结果

lijianbin9 2010-03-22 11:03:50
怎么用Eclipse实现以下结果

...全文
116 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xinguohit 2010-03-22
  • 打赏
  • 举报
回复
写个程序不容易,楼主别忘了结贴......
lijianbin9 2010-03-22
  • 打赏
  • 举报
回复
ok 啦,,谢谢!
import java.util.Scanner;
public class test1 {
public static void main(String[] args) {
String c = " ";
int floor;
System.out.print("please input a num:");
Scanner IC = new Scanner (System.in);
floor = IC.nextInt();
// System.out.

System.out.println(floor);
for(int i=floor-1; i>=0; i--){
for(int j=0;j<i;j++){
System.out.print(c);
}
for(int k=1;k+i<=floor;k++){
System.out.print(k);
}
for(int m=floor;m-i>1;m--){
System.out.print(m-i-1);
}
System.out.println();
}
}
}
wang12 2010-03-22
  • 打赏
  • 举报
回复
Eclipse,工具而已
_zoro 2010-03-22
  • 打赏
  • 举报
回复
是啊 用嵌套循环就可以了
基础课程
  • 打赏
  • 举报
回复
是啊
和工具没啥关系

打印呗
xinguohit 2010-03-22
  • 打赏
  • 举报
回复
这个不是很难,多用几次循环就行了,代码如下:

public class Test {
public static void main(String[] args) {
String c = " ";
int floor = 5; //需要几层就将floor设成几;
System.out.println(floor);
for(int i=floor-1; i>=0; i--){
for(int j=0;j<i;j++){
System.out.print(c);
}
for(int k=1;k+i<=floor;k++){
System.out.print(k);
}
for(int m=floor;m-i>1;m--){
System.out.print(m-i-1);
}
System.out.println();
}
}
}
yiban1315193 2010-03-22
  • 打赏
  • 举报
回复
按序输出就可以

62,624

社区成员

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

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