Re: [問題] 可以幫解這題嗎(急) (附上程式碼)

看板java作者 (骨頭)時間19年前 (2006/04/11 14:34), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《boubouy.bbs@bbs.cgu.edu.tw ( 放空中)》之銘言: : 恩 我大概知道要把它傳進去但是不知道該怎麼傳進去 : index這個陣列我是想把使用者所輸入的數字放入這個陣列裡面 : 然後應該要把這個陣列傳進去可是傳進去的這個動作我寫不出來 其實只要多寫一個constructor 然後把array當參數丟過去就好了 本來是想說都會寫intArray來做運算了 這應該不是問題..orz intArray(int[] inputAry){ input=inputAry; } ---------------------------- intArray ary=new intArray(index); ---------------------------- 如果看不懂 , 回去翻翻關於OO或class的章節吧. 把method跟constructor的parameter傳遞的概念搞懂 不然就不要勉強用method跟class , 直接用你的index陣列做計算 至於題目程式碼的部分 , 在判斷輸入的地方 , 這樣不管怎麼寫 n 都是10 , 就是你輸入的東西被限定在十個了. GL & HF -- String[] inputAry=scan.nextLine().split("[ +]"); for(int i= 1-inputAry.length%2;i<inputAry.length;i+=2) System.out.print(inputAry[i]+" "); System.out.println(); -- String temp="relax"; | Life just like programing while(buringlife) String.forgot(temp); | to be right or wrong while(sleeping) brain.setMemoryOut(); | need not to say stack.push(life.running); | the complier will stack.push(scouting.buck()); | answer your life stack.push(bowling.pratice()); | Bone everything -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.138.240.57
文章代碼(AID): #14EquHOy (java)
文章代碼(AID): #14EquHOy (java)