作者TonyQ (骨头)
看板java
标题Re: [问题] 可以帮解这题吗(急) (附上程式码)
时间Tue Apr 11 14:58:02 2006
※ 引述《[email protected] ( 放空中)》之铭言:
: 恩 我大概知道要把它传进去但是不知道该怎麽传进去
: 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