Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 766|回复: 2
打印 上一主题 下一主题

问题已解~~

[复制链接]

33

主题

15

好友

964

积分

青铜长老

Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

跳转到指定楼层
1#
发表于 2011-9-16 03:33 PM |只看该作者 |倒序浏览
本帖最后由 seongchog 于 2011-9-16 06:09 PM 编辑

谢谢你们问题已解~~




收藏收藏0

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

2#
发表于 2011-9-16 04:08 PM |只看该作者
Question 1
Write an application that displays the following pattern as output. by using for loops.
You shall use the output statements that print a single asterisk (*), a single space or a single newline character.  Maximum your use of repetition and minimize the number of output statement.

*********
  *******
   *****
     ***
      *
     ***
    *****
   *******
  *********

这是我的code:
  int i, j;



        for (i = 4; i > 0; i--) {
            for (j = i; j < 4; j++) {
                System.out.print(" ");
            }

            for (j = i; j > 0; j--) {
                System.out.print("*");
            }

            for (j = i; j > 0; j--) {
                System.out.print("*");
            }
  


            
            
            
            System.out.println();                                
            
            
        
    }
}}

My Output:

********
  ******
   ****
    **
seongchog 发表于 2011-9-16 03:33 PM


樓主你在一開始就只設定 i=4 的情况下,當然會造成 Output 只出現 4 行的结果
for (i = 4; i > 0; i--)


回复

使用道具 举报

33

主题

15

好友

964

积分

青铜长老

Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

3#
发表于 2011-9-16 06:10 PM |只看该作者
问题已解~~谢谢你


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-25 12:23 PM , Processed in 0.123937 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部