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/cn.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灯, 水草

请输入看板名称,例如:Soft_Job站内搜寻

TOP