魔獸傳奇

          java程序愛(ài)好者
          posts - 28, comments - 16, trackbacks - 0, articles - 6
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          求java算法

          Posted on 2008-04-02 12:50 龍旋風(fēng) 閱讀(303) 評(píng)論(2)  編輯  收藏
           一個(gè)需用2層的for循環(huán)處理的例子,誰(shuí)能給出算法:
                                                                1
                                                               22
                                                              323
                                                             4234
                                                            52345

          評(píng)論

          # re: 求java算法  回復(fù)  更多評(píng)論   

          2008-04-04 18:47 by Empressement Conduct
          public class Jinzita {

          int i,j;

          public Jinzita() {
          }

          void means(){

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

          System.out .print(i+" ");

          for(j=2; j<=i; j++){
          System.out .print(j+" ");
          }
          System.out.println();
          }
          }

          public static void main(String[] args) {
          Jinzita num = new Jinzita();
          num.means();
          }
          }


          兄弟 你試試上邊的程序 應(yīng)該沒(méi)問(wèn)題的
          或者 下面的程序 其實(shí)一個(gè)樣
          public class Jinzita {

          public Jinzita() {
          }

          public static void main(String[] args) {

          int i,j;
          for(i=1; i<=5; i++){
          for(j=0; j<5-i; j++){
          System.out.print(" ");
          }

          System.out .print(i+" ");

          for(j=2; j<=i; j++){
          System.out .print(j+" ");
          }
          System.out.println();
          }
          }
          }

          # re: 求java算法  回復(fù)  更多評(píng)論   

          2008-04-05 17:18 by jackiesmiht
          謝了,兄弟,測(cè)試通過(guò)!

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 夏河县| 蒲城县| 井冈山市| 军事| 英吉沙县| 鄄城县| 西林县| 来安县| 舞钢市| 波密县| 车险| 海晏县| 庆城县| 毕节市| 赤城县| 罗城| 普格县| 桂平市| 鹿邑县| 海宁市| 南投市| 来宾市| 大同市| 大厂| 东乡县| 时尚| 寿光市| 拉孜县| 高淳县| 阳朔县| 介休市| 松溪县| 德钦县| 台东县| 黄浦区| 洪江市| 巫山县| 凤冈县| 宾阳县| 信宜市| 襄城县|