瘋狂講義第四章 流程式控制制和數組__演算法

來源:互聯網
上載者:User

1. 三種程式的控制結構

if else, switch, for ,while ,do-while, foreach.

理解foreach的實現實質,以及使用注意事項。

2. 迴圈控制結構

break, continue,return 外加保留的goto.

外層迴圈的控制, 利用迴圈外面定義的結束標籤 outer: 可以控制迴圈的層次。

3. 數組的定義和初始化,在記憶體中的布局。


4 java.util.Arrays;

void sort(type[] a):

採用的排序演算法介紹:

sort

public static void sort(long[] a,                        int fromIndex,                        int toIndex)
對指定 long 型數組的指定範圍按數字升序進行排序。排序的範圍從索引 fromIndex(包括)一直到索引 toIndex(不包括)。(如果 fromIndex==toIndex,則排序範圍為空白。)

該排序演算法是一個經過調優的快速排序法,改編自 Jon L. Bentley 和 M. Douglas McIlroy 合著的 Engineering a Sort Function", Software-Practice and Experience Vol. 23(11) P. 1249-1265 (November 1993)。此演算法在許多資料集上提供 n*log(n) 效能,這導致其他快速排序會降低二次型效能。

參數: a - 要排序的數組 fromIndex - 要排序的第一個元素的索引(包括) toIndex - 要排序的最後一個元素的索引(不包括) 拋出: IllegalArgumentException - 如果 fromIndex > toIndex ArrayIndexOutOfBoundsException - 如果 fromIndex < 0 或 toIndex > a.length


5. 兩個小型的練習項目:數字型浮點數人民幣轉換成字串的漢子讀法, 五子棋的實現

(1)浮點型資料轉換成漢子字串人民幣讀法

分析:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.