NTU-Exam 板


LINE

課程名稱︰高等程式設計 課程性質︰選修 課程教師:劉邦鋒 開課學院:電資學院 開課系所︰資工所、網媒所 考試日期(年月日)︰2013.06.18 考試時限(分鐘): 試題 : Advanced Computer Programming 2013 Final Examination National Taiwan University 06/18/2013 NOTE: You need to finish the writing part before doing the programming part. Writing Part: (1) Polymorphism (10%) ˙ Describe the principle and purpose of polymorphism. Please use a complete example in C++ to illustrate your points. (5%) ˙ Please describe the mechanisms in C++ that make polymorphism possible. The key words include virtual functions, class hierarchy, and pointers/references. (5%) (2) Accessing Data Member (10%) Describe the difference between private, protected, and public data members in C++. You should focus on the purpose of these different mechanisms, and how to achieve the purpose with these data access methods. Please give a complete example for each of them in C++, and illustrate your points. (3) Template Programming (10%) Describe the purpose of template programming. You should focus on the template mechanism, and how the mechanism achieves the purpose. Please give a complete example in C++ to illustrate your points. (4) Operator Overloading (10%) Describe the purpose of operator overloading. Give a complete example of operator overloading in C++, and explain why operator overloading can achieve these purposes. (5) Dynamic Programming (10%) ˙ What are the three principles of dynamic programming? Please use an example to illustrate these principles. (7%) ˙ What is the major difference between dynamic programming and exhaustive search? (3%) Programming Part: (1) Scheduler (10%) We want to schedule many courses into a classroom. Each course has a starting time and an ending time. The classroom can be used at any time, but it can only accommodate one course at a time. If two courses overlap then we cannot select them both. Now please write a program that selects as many courses as possible. (1.1) Input The first line of the input is the number of test cases T. Each test case starts with a line consisting of the number of courses C. The i-th of the following line has two integers, the starting time S_i and the ending time E_i. (1.2) Output The output consists of T lines. The i-th line has the maximum number of courses that can be selected in the i-th test case. (1.3) Technical Specification ˙ 1 ≦ T ≦ 50 ˙ 1 ≦ C ≦ 10^5 ˙ 0 ≦ S_i, E_i ≦ 2^32 (32-bit unsigned integer) (1.4) Sample Input 2 3 3 6 2 4 3 7 3 2 4 3 6 4 7 (1.5) Sample Output 1 2 (2) Lights Off (20%) We want to play a game called "Turn the lights off". Now we have 16 lights as a 4 by 4 array. Each light can be either on or off. Each light has a switch. The switch is designed so that if we toggle a switch, the status of this light, and the four neighboring lights will change their status. By changing the status we mean if the light is on then it will become off, and if it is off then it will become on. Note that if you toggle a switch around the boundary or the corner, then the number of its neighboring lights is 3 or 2, not 4. Now given the initial status of the lights, please find the minimum number of switches one has to toggle in order to turn off all the lights. There are two subtasks: 1. In the first subtask we ensure that we can use all of the switches. Please refer to the description and the input format for more details. (10%) That is, the last four line of the test case will be: .... .... .... .... 2. In the second subtask some switches may be broken. What is the minimum number of switches to toggle in order to turn off all lights? Note that the lights are independent from the switches and all lights are functional. For example, even if a switch is broken, its light will still change status if the switch next to it is toggled. It is just that in this subtask some switch cannot be used. (10%) (2.1) Input The first line of input is the number of test case T. Each test case contains 8 lines, each line with four-character string. The first four strings are the status of the lights as in the first subtask. The next four strings are the status of the switch - a '.' (character "dot") means off and an 'O' (letter O, not number) means on. The last four lines of test case indicates if the switch is broken - a dot '.' means that it works and an 'X' means that it is broken. (2.2) Output For each test case output the minimum number of switches to toggle in order to turn off all the lights. Print '-1' if it is impossible to turn off all the lights. (2.3) Technical Specification ˙ 1 ≦ T ≦ 50 (2.4) Sample Input 4 .... .... .... .... .... .... .... .... ..OO ...O .... .... .... .... .... .... .... .... .... .... XXXX XXXX XXXX XXXX ..OO ...O .... .... ..XX ...X .... .... (2.5) Sample Output 0 1 0 -1 (3) Builder (20%) We want to build an L-shape house in an N by N grid. Every sides of the house should align to the grid. Note that the width and length of this house is a power of 2, and is at least 2. Some cells in this grid is not suitable for building houses and should be avoided. Now please determine the maximum size of the house that can be built, and the number of possible placements on which we can build the largest houses. Note that the house can be rotated in four different orientations, and it is guaranteed that there will be at least one position that we can build the house. The places for building the largest house can overlap. For example, here are 4 size-2 L-shape houses in different directions: OOOO OOOO OO OO OOOO OOOO OO OO OO OO OOOO OOOO OO OO OOOO OOOO There are two subtasks: 1. In the first subtask we ensure that in any 2 by 2 cells in the grid, at least one of the cell is bad for construction. (6%) 2. The second subtask removes the condition given in subtask 1. The input and output specification are same as those of the first subtask. (14%) (3.1) Input The first line of the input is the number of test cases T. The first line of the test case has the size of the grid N, then followed by N lines. Each of the N lines has a string indicating the status of the grid. If the character in the string is a '.' then the cell is good for construction. If the character is an 'X' then the cell is bad. (3.2) Output Each test case should output two numbers in a line. The first number is the size of the largest house one can build, and the second is the number of placements that we can build this house. (3.3) Technical Specification ˙ 1 ≦ T ≦ 10 ˙ 2 ≦ N ≦ 500 (3.4) Sample Input 3 3 ... .X. ... 3 ... ... ... 4 ..XX ..XX .... .... (3.5) Sample Output 2 4 2 16 4 1 --



※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.231.132.45
※ 文章網址: https://webptt.com/m.aspx?n=bbs/NTU-Exam/M.1461419315.A.CE0.html
1F:→ rod24574575 : 已收資訊系! 04/23 21:50







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:BuyTogether站內搜尋

TOP