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

BookBub brings you free & bargain national bestselling eBooks in the genres of your choice! Sign up now & join 1.5 million happy readers.
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
    全站熱搜

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