close
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
    全站熱搜
    創作者介紹
    創作者 jmuko103 的頭像
    jmuko103

    2016台北年菜推薦 年菜食譜 , 年菜預購 , 年菜2015 , 年菜訂購 , 7 eleven年菜訂購 , 年菜宅配 , 年菜菜單 , 年菜推薦 , 年菜食譜大全 , 年菜2016 , 年菜外帶 , 外帶年菜 台中

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