Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中 
Free Bestselling eBooks

Free national bestsellers for your eReader - Fiction, Nonfiction & more! Join 1.5 million book lovers now. Sign-up in under 10 seconds to get the free daily email.
From our sponsors
java程式問題
Dec 27th 2013, 08:32

以下程式是"輸入10個數值,放入陣列中,並做排序"
String S1;
Integer sort[] = new Integer[10];
for (int i=0;i
{
S1 = JOptionPane.showInputDialog("請輸入一個整數進行排序:");
sort[i] = Integer.parseInt(S1);
}
Arrays.sort(sort); //利用Arrays.sort做排序
for (int ary : sort)
System.out.print(ary+" | ");

//利用Math.max()找出最大值
int temp = sort[0]; //使temp=第一個值
for (int i=0;i<sort.length;i++)
temp = Math.max(temp, sort[i]);
int max = temp;
System.out.println("\n最大值= "+max);

Q1
執行順序是?

Q2
如果我不想只設定成10個數字呢?
需要改哪裡讓程式為彈性?(意思是輸入多少個數字都可以)

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 jmuko100 的頭像
    jmuko100

    2015年假公告, 2015年假幾天, 2015年假公告人事行政局, 2015年假放幾天, 2015行事曆, 2015 國定假日, 2015年假日期, 2015年假9天, 明年假期2015, 2015 年假,

    jmuko100 發表在 痞客邦 留言(0) 人氣()