Free考研资料 - 免费考研论坛

 找回密码
 注册
打印 上一主题 下一主题

【合集】2006年上海交大计算机研究生考试复试上机题目

[复制链接]
跳转到指定楼层
楼主
wajd 发表于 06-4-4 10:30:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
发信站: 饮水思源 (2006年03月31日16:38:26 星期五), 站内信件

☆──────────────────────────────────────☆
     davidsoft (david) 于 2006年03月29日22:47:23 星期三)
提到:

录取了,哈哈,共享考试题目积攒RP。^_^

编程环境:VC+6
考试时间:3小时
本题目是懒猪我一字一字敲上电脑的,转载请尊重懒猪的劳动成果,注明转自懒猪的窝窝
http://spaces.msn.com/davidblogs/
资源共享,谢谢合作。
懒猪稍后给出自己做的参考解答,希望能和大家多多交流。

Problem A.Fibonacci
Input:        fib.in
Output:       Standard Output
Time limit:   5 second
Memory limit: 64 megabytes
Offerd by :   http://spaces.msn.com/davidblogs/

The Fibonacci Numbers{0,1,1,2,3,5,8,13,21,34,55...} are defined by the recurre
nce:
F0=0 F1=1 Fn=Fn-1+Fn-2,n>=2
Write a program to calculate the Fibonacci Numbers.

Input
The input file contains a number n and you are expected to calculate Fn.(0<=n<
=30)
Output
Print a number Fn on a separate line,which means the nth Fibonacci Number.

Example
fib.in       Standard Output
1            1
2            1
3            2
4            3
5            5
6            8

Problem B.WERTYU
Input:         wertyu.in
Output:        Standard Output
Time limit:    5 second
Memory limit:  64 megabytes
Offerd by :   http://spaces.msn.com/davidblogs/

A common typing error is to place the hands on the keyboard one row to the rig
ht of the correct position.So "Q" is typed as "W" and "J" is typed as "K" and
so on.You are to decode a message typed in this manner.

` 1 2 3 4 5 6 7 8 9 0 - = BackSp
Tab Q W E R T Y U I O P [ ] \
A S D F G H J K L ; ' Enter
Z  X  C  V  B  N  M  ,  .  /
Control Alt  Space  Alt Control

Input
The input file consist of several lines of text.Each line may contain digits,s
paces,upper case letters(except Q,A,Z),or punctuation shown above(except back-
quote(') which is left to the key "1").Keys labelled with words [Tab,BackSp,Co
ntrol,etc.] are not represented in the input.

Output
You are to replace each letter or punctuation symbol by the one immediately to
its left on the QWERTY keyboard shown above.Spaces in the input should be ech
oed in the output.

Example
wertyu.in               Standard Output
O S, GOMR YPFSU/        I AM FINE TODAY.

Problem C.String Matching
Input:         matching.in
Output:        Standard Output
Time limit:    5 second
Memory limit:  64 megabytes
Offerd by :   http://spaces.msn.com/davidblogs/

Finding all occurrences of a pattern in a text is a problem that arises freque
ntly in text-editing programs.

Typically,the text is a document being edited,and the pattern searched for is
a particular word supplied by the user.

We assume that the text is an array T[1..n] of length n and that the pattern i
s an array P[1..m] of length m<=n.We further assume that the elements of P and
T are all alphabets(∑={a,b...,z}).The character arrays P and T are often cal
led strings of characters.

We say that pattern P occurs with shift s in the text T if 0<=s<=n and T[s+1..
s+m] = P[1..m](that is if T[s+j]=P[j],for 1<=j<=m).

If P occurs with shift s in T,then we call s a valid shift;otherwise,we call s
a invalid shift.

Your task is to calculate the number of vald shifts for the given text T and p
attern P.

Input
In the input file,there are two strings T and P on a line,separated by a singl
e space.You may assume both the length of T and P will not exceed 10^6.

Output
You should output a number on a separate line,which indicates the number of va
lid shifts for the given text T and pattern P.

Example
matching.in     Standard Output
aaaaaa a        6
abababab abab   3
abcdabc abdc    0

Problem D.Exponential Form
Input:         form.in
Output:        Standard Output
Time limit:    5 second
Memory limit:  64 megabytes
Offerd by :   http://spaces.msn.com/davidblogs/

Every positive number can be presented by the exponential form.For example,
137 = 2^7 + 2^3 + 2^0

Let's present a^b by the form a(b).Then 137 is presented by 2(7)+2(3)+2(0).
Since 7 = 2^2 + 2 + 2^0 and 3 = 2 + 2^0 , 137 is finally presented by 2(2(2)+2
+2(0))+2(2+2(0))+2(0).

Given a positive number n,your task is to present n with the exponential form
which only contains the digits 0 and 2.

Input
The input file contains a positive integer n (n<=20000).

Output
You should output the exponential form of n an a single line.Note that,there s
hould not be any additional white spaces in the line.

Example
form.in
137
Stardard Output
2(2(2)+2+2(0))+2(2+2(0))+2(0)
form.in
1315
Stardard Output
2(2(2+2(0))+2)+2(2(2+2(0)))+2(2(2)+2(0))+2+2(0)


☆──────────────────────────────────────☆
您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系我们|Free考研资料 ( 苏ICP备05011575号 )

GMT+8, 24-11-13 07:52 , Processed in 0.079481 second(s), 11 queries , Gzip On, Xcache On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表