Board logo

標題: [疑難] JAVA 問題~~~我不知道如何繼續? [打印本頁]

作者: 珊~shan~    時間: 2009-3-9 01:37     標題: JAVA 問題~~~我不知道如何繼續?

我寫到一半不知道怎樣寫下去>.<

public class YK1 {
    public static void main(String[] argv){ // a class method which can be called by JVM
        int[] mydata = {5,9,1,3,7,11,2,8};
        OrderedList ol = new OrderedList(mydata);// create a OrderedList object by the constructor with one argument
        //ol is a reference to an OrderedList object, not an object itself.
        ol.print(); // pass the print messsge to object pointed byol,this will effectly call the prin() method defind in OrderedList.
        System.out.println("Smallest number is " + ol.deleteMin());
        System.out.println("The next smallest number is "+ol.deleteMin());
        ol.print();

我想問下...如果我要用一個迴圈 是用ramdon寫由1-100的隨機產生1個數...共做10次...之後再寫一去清空deletnMin

應該HOW TO DO???
作者: jayzhou_2046    時間: 2009-3-9 17:46     標題: 回復 1# 的帖子

不了解閣下提及的OrderedList.  是J2SE包含的, 還是閣下開發的類別?
關於random閣下可以看一下以下的for廻圈及亂數的產生方法:
for (int i = 0; i < 10; i++) {
        System.out.println((int)(Math.random() * 100));
}




歡迎光臨 香港 Xocat Forum 討論區 (http://p.xocat.com/p/) Powered by Discuz! 6.0.0