Lab Hours
Extra Labs
Lab 2-3
• 修改Lab 2的程式碼,輸出團體⼈人數最多的⼈人數。
• Modify your solution to Lab 2 so that the program outputs the max number of group members.
Lab 2-4
• 最初,我們假設friendship array的每⼀一個元素都不會重複。
• 但是真實世界中,有些⼈人就是⼈人緣超好!
• 現在開放⼤大家隨意填寫⾃自⼰己最要好的朋友 (也就是說可能會 出現重複的數字)。 如何產⽣生可能重複的數字?
• 修改Lab 2的程式碼,使得程式輸出⼈人緣最好的⼈人。 可能會有
⼀一個以上的⼈人都是⼈人緣最好,該怎麼辦?
Lab 2-4
• Recall that we assume a friendship array with distinct integers.
• However, some people are more popular among us.
• Now consider that one could write down his/her most
intimate friend (that is, there exist duplicates of numbers).
How to generate random integers which could be duplicate?
• Modify your solution to Lab 2 so that the program outputs the most popular person among us. If there are two (or more) of
Memory & You
• 根據最後⼀一⾴頁投影片的程式碼,畫出該程式碼在記憶體模
型中的配置。
• 你需要標⽰示出記憶體中儲存在stack下的區域變數與儲存在 heap中的物件。
• 對於所有的reference,你需要⽤用箭頭符號連結該變數與物 件。
Memory & You
• Plot the scheme of memory allocation for the program shown in the next page.
• You should indicate the local variables in the stack and the objects in the heap.
• For all reference variables, you need to draw the arrow from the reference to the object.