上海交通大学2005-2007年计算机上机真题附答案(4)

本站小编 免费考研网/2016-08-04


le.

15

Output
For each completely specified binary tree in the input file, the level order t
raversal of that tree should be printed. If a tree is not completely specified
, i.e., some node in the tree is NOT given a value or a node is given a value
more than once, then the string ``not complete'' should be printed.
Sample Input
(11,LL) (7,LLL) (8,R)
(5,) (4,L) (13,RL) (2,LLR) (1,RRR) (4,RR) ()
(3,L) (4,R) ()
Sample Output
5 4 8 11 13 4 7 2 1
not complete
参考试题3:
写一个求任意边平面多边形面积的程序
要求是:输入边数,然后依次输入每个顶点的坐标
有可能输入的数值不能构成正则多边形,也即,边与边之间发生了交叉,比如,四个顶
点分别为(0,0),(1,1),(0,1),(1,0)这种情况,这时候,请打印出“imp
ossible"字样;如果多边形合法,则请输出该多边形的面积
要注意的情况是:凹多边形的正确处理
Sample Input
5

16

0 0
0 1
0.5 0.5
1 1
1 0
Sample Output
0.75
Sample Input
4
0 0
0 1
1 0
1 1
Sample Output
Impossible
保送生试题:
Problem D . Code the Tree
Source File: tree.cpp Time limited: 1 second
Input File: tree.in Output File:tree.out
A tree(ie:a connected graph without cycles) with vertices numbered by the inte
gers 1,2....,n is given. The "Prufer" code of such a tree is built as follows:
the leaf(a vertex that is incident to only one edge) with the minimal number i
s taken. This leaf, together with its incident edge is removed from the graph,
while the number of the vertex that was adjacent to the leaf is written down.

17

In the obtained graph, this procedure is repeated, until there is only one ve
rtex left(which, by the way, always has number n). The written down sequence o
f n - 1 numbers is called the Prufer code of the tree.

Your task is, given a tree, to compute its Prufer code. The tree is denoted by
a word of the language specified by the following grammar:

T::= (N S)
S::= ,T S | empty
N::= integer


That is, trees have parentheses around them, and a number denoting the identif
ier of the root vertex, followed by arbitrarily many(maybe none) subtrees sepa
rated by a single comma character. As an example, take a look at the tree in t
he figure below which is denoted in the first example.


Note that, according to the definition given above, the root of a tree may be
a leaf as well. It is only for the ease of denotation that we designate some v
ertex to be the root. Usually, what we are dealing here with is called an "unr
ooted tree".


Input:
There is only one line in the input, which specifies a tree as described above
. You may assume that 1 <= n <= 50.
Output:
Generate a single line containing the Prufer code of the tree. Separate number
s by a single space. Do not print any spaces at the end of the line.



Sample input and output
tree.in
(2,(6,(7)),(3),(5,(1),(4)),(8))
tree.out
5 2 5 2 6 2 8
2007 年复试上机真题:
Problem A. Old Bill
Input file: standard input
Output file: standard output
Among grandfather's papers a bill was found.
72 turkeys $_679_
The first and the last digits of the number that obviously represented the
total price of those turkeys are replaced here by blanks (denoted _), for
they are faded and are illegible. What are the two faded digits and what
was the price of one turkey?
We want to write a program that solves a general version of the above
problem.
N turkeys $_XYZ_
The total number of turkeys, N, is between 1 and 99, including both. The
total price originally consisted of five digits, but we can see only the
three digits in the middle. We assume that the first digit is nonzero, that
the price of one turkeys is an integer number of dollars, and that all the
turkeys cost the same price.

19

Given N, X, Y, and Z, write a program that guesses the two faded digits and
the original price. In case that there is more than one candidate for the
original price, the output should be the most expensive one. That is, the
program is to report the two faded digits and the maximum price per turkey
for the turkeys.

Input
The first line of the input file contains an integer N (0<N<100), which
represents the number of turkeys. In the following line, there are the

相关话题/计算机

  • 领限时大额优惠券,享本站正版考研考试资料!
    大额优惠券
    优惠券领取后72小时内有效,10万种最新考研考试考证类电子打印资料任你选。涵盖全国500余所院校考研专业课、200多种职业资格考试、1100多种经典教材,产品类型包含电子书、题库、全套资料以及视频,无论您是考研复习、考证刷题,还是考前冲刺等,不同类型的产品可满足您学习上的不同需求。 ...
    本站小编 Free壹佰分学习网 2022-09-19
  • 2008年上海交通大学计算机考研复试上机试题
    本站小编 免费考研网 2016-08-04
  • 2016年东北大学计算机专业基础考研真题(完整版)
    2016年东北大学计算机专业基础考研真 题(完整版)凯程首发 一、简答 1、 循环语句while和dowhile的区别。 2、 有static声明的局部变量和自由变量的区别。 3、 根据 4、Int (*p)[4]和int *p[4]的区别 二、写出程序运行的结果 有一个是用指针作函数参数,实现数据的交换 有一个是a[9]={1, ...
    本站小编 免费考研网 2016-07-31
  • 2009-2015年计算机组成原理考研大题
    43.(8 分)某计算机的 CPU 主频为 500MHz,CPI 为 5(即执行每条指令平均需 5 个时钟周期)。假定某外设的数据传输率为 0.5MB/s,采用中断方式与主机进行数据传送,以 32 位为传输单位,对应的中断服务程序包含 18 条指令,中断服务的其他开销相当于 2 条指 令的执行时间。请回答下列问题,要求给出计算过程。 (1) ...
    本站小编 免费考研网 2016-07-31
  • 2009-2015年计算机组成原理考研选择题
    11.冯诺依曼计算机中指令和数据均以二进制形式存放在存储器中,CPU 区分它们的依据是 。 A.指令操作码的译码结果 B.指令和数据的寻址方式 C.指令周期的不同阶段 D.指令和数据所在的存储单元 11.C。考查指令的执行过程。 通常完成一条指令可分为取指阶段和执行 ...
    本站小编 免费考研网 2016-07-31
  • 计算机科学与技术考研报考注意事项
    计算机科学与技术考研报考注意事项 近几年由于专业的热门和考研竞争的异常激烈,因此国内一些重点院校的计算机专业硕士生入学分数都非常高,这种情况在一些重点院校特别突出。报考计算机专业研究生的朋友一定要充分地认清这种现实情况,做好充分的准备,思想上要树立考试胜利的信心,并且做好刻苦复习 ...
    本站小编 免费考研网 2016-07-27
  • 计算机科学与技术专业解析
    计算机科学与技术专业解析  一、培养目标   本专业培养和造就适应现代化建设需要。德智体全面发展、基础扎实、知识面宽、能力强、素质高具有创新精神,系统掌握计算机硬件、软件的基本理论与应用基本技能,具有较强的实践能力,能在企事业单位、政府机关、行政管理部门从事计算机技术研究和应用 ...
    本站小编 免费考研网 2016-07-27
  • 计算机软件与理论就业方向与就业前景
    计算机软件与理论就业方向与就业前景 计算机科学与技术专业介绍   计算机科学与技术是研究计算机的设计与制造,以及信息获取、表示、存储、处理、传输和利用等方面的理论、原则、方法和技术的学科。它包括科学与工程技术两方面,两者互为作用,高度融合,这是计算机科学与技术学科的突出特点。计 ...
    本站小编 免费考研网 2016-07-27
  • 计算机应用技术就业方向与就业前景
    计算机应用技术就业方向与就业前景 计算机应用技术专业介绍   计算机应用技术是计算机科学与技术专业下设的一个二级学科,某些院校可以授予理学学位,在此针对工学学位进行解析。本学科主要研究计算机各种应用中具有共性的理论、技术和方法,以及各种前沿性、创新性的计算机应用。   计算 ...
    本站小编 免费考研网 2016-07-27
  • 计算机系统结构就业方向与就业前景
    计算机系统结构就业方向与就业前景 计算机系统结构专业介绍   计算机系统结构是计算机科学与技术专业下设的二级学科。某些院校可以授予理学学位,在此针对工学学位进行解析。计算机系统结构是计算机的的机器语言程序员或编译程序编写者所看到的外特性。所谓外特性,就是计算机的概念性结构和功能 ...
    本站小编 免费考研网 2016-07-27
  • 北京邮电大学计算机学院简介
    北京邮电大学计算机学院简介 北京邮电大学计算机学院源于1985年9月成立的北京邮电大学计算机工程系,后经多次机构调整和更名,2008年9月由计算机科学与技术专业、网络工程专业、智能科学与技术专业和信息安全专业合并形成了现在的计算机学院。   计算机学院是全校规模大、综合实力强的 ...
    本站小编 免费考研网 2016-07-27