ImageVerifierCode 换一换
格式:DOCX , 页数:73 ,大小:37.88KB ,
资源ID:5457726      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5457726.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(华东师范大学计算机机试真题.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

华东师范大学计算机机试真题.docx

1、华东师范大学计算机机试真题2009机试计算和的数位Sum of digit Description Write a program which computes the digit number of sum of two integers a and b. Input The first line of input gives the number of cases, N(1 N 100). N test cases follow.Each test case consists of two integers a and b which are separeted by a space in

2、 a line. (0=a,b=100000000). Output For each test case, print the number of digits of a + b. Sample Input 35 71 991000 999 Sample Output 234 #includeint main()int n;int a,b;int sum;while(scanf(%d,&n)!=EOF)while(n-) int an=0; scanf(%d%d,&a,&b); sum=a+b; while(sum) an+; sum/=10; printf(%dn,an+);return

3、0;大写改小写Capitalize Description Write a program which replace all the lower-case letters of a given text with the corresponding captital letters. Input A text including lower-case letters, periods, and space.Output Output The converted text. Sample Input welcome to east china normal university. Sample

4、 Output WELCOME TO EAST CHINA NORMAL UNIVERSITY. #include#includechar str1000;int main()int l;while(gets(str)l=strlen(str);int i;for(i=0;i=a&stri=z)printf(%c,stri-32);elseprintf(%c,stri);printf(n);return 0;素数对Primes Pair Description We arrange the numbers between 1 and N (1 = N = 10000) in increasin

5、g order and decreasing order like this: 1 2 3 4 5 6 7 8 9 . . . NN . . . 9 8 7 6 5 4 3 2 1Two numbers faced each other form a pair. Your task is to compute the number of pairs P such that both numbers in the pairs are prime. Input The first line of input gives the number of cases, C (1 C 100). C tes

6、t cases follow.Each test case consists of an integer N in one line. Output For each test case, output P . Sample Input 414751 Sample Output 0226 #include#includebool prime10005;void init()int i;int j;prime0=prime1=false;/不是素数prime2=true;/是素数for(i=3;i=10005;i+=2)primei=true;/是素数primei+1=false;/不是素数 除

7、0和2之外的偶数都不是素数for(i=3;i=10005;i+=2)if(primei=true)/是素数j=i+i;while(j=10005)primej=false;/不是素数j+=i;int main()int c;int n;init();/初始化while(scanf(%d,&c)!=EOF)while(c-)scanf(%d,&n);int sum=0;int i;for(i=2;i=n/2;i+)if(primei=true&primen+1-i=true)sum+;sum*=2;if(n%2=1)/n为奇数if(primen/2+1=true)sum+=1;printf(%d

8、n,sum);return 0;求最大公约数和最小公倍数GCD and LCM Description Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b (0 a, b 44000). Input The first line of input gives the number of cases, N(1 N 100). N test cases follow.Each test case contains t

9、wo interger a and b separated by a single space in a line. Output For each test case, print GCD and LCM separated by a single space in a line. Sample Input 28 65000 3000 Sample Output 2 241000 15000 #includeint getgcd(int a,int b)int gcd;int t1,t2;t1=a;t2=b;gcd=t1%t2;while(gcd!=0)t1=t2;t2=gcd;gcd=t1

10、%t2;return t2;int main()int n;int a,b;while(scanf(%d,&n)!=EOF)while(n-)scanf(%d%d,&a,&b);printf(%d %dn,getgcd(a,b),a*b/(getgcd(a,b);return 0;排序后求位置处的数Sort it Description There is a database,partychen want you to sort the databases data in the order from the least up to the greatest element,then do t

11、he query: Which element is i-th by its value?- with i being a natural number in a range from 1 to N.It should be able to process quickly queries like this. Input The standard input of the problem consists of two parts. At first, a database is written, and then theres a sequence of queries. The forma

12、t of database is very simple: in the first line theres a number N (1=N=100000), in the next N lines there are numbers of the database one in each line in an arbitrary order. A sequence of queries is written simply as well: in the first line of the sequence a number of queries K (1 = K = 100) is writ

13、ten, and in the next K lines there are queries one in each line. The query Which element is i-th by its value? is coded by the number i. Output The output should consist of K lines. In each line there should be an answer to the corresponding query. The answer to the query i is an element from the da

14、tabase, which is i-th by its value (in the order from the least up to the greatest element). Sample Input 5712112371213325 Sample Output 1217123#include#includeusing namespace std;int num100010;int pos105;int main()int n;int i;int k;while(scanf(%d,&n)!=EOF)for(i=1;i=n;i+)scanf(%d,&numi);scanf(%d,&k)

15、;for(i=1;i=k;i+)scanf(%d,&posi);sort(num+1,num+1+n);for(i=1;i=k;i+)printf(%dn,numposi);return 0;*路由器连接Hub Connection plan Description Partychen is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the company, they can be connected to

16、each other using cables. Since each worker of the company must have access to the whole network, each hub must be accessible by cables from any other hub (with possibly some intermediate hubs). Since cables of different types are available and shorter ones are cheaper, it is necessary to make such a

17、 plan of hub connection, that the cost is minimal. partychen will provide you all necessary information about possible hub connections. You are to help partychen to find the way to connect hubs so that all above conditions are satisfied. Input The first line of the input contains two integer numbers

18、: N - the number of hubs in the network (2 = N = 1000) and M - the number of possible hub connections (1 = M = 15000). All hubs are numbered from 1 to N. The following M lines contain information about possible connections - the numbers of two hubs, which can be connected and the cable cost required

19、 to connect them. cost is a positive integer number that does not exceed 106. There will always be at least one way to connect all hubs. Output Output the minimize cost of your hub connection plan. Sample Input 4 61 2 11 3 11 4 22 3 13 4 12 4 1 Sample Output 3#include#includeusing namespace std;stru

20、ct Edgeint a,b;int cost;E15010;int Tree1010;int findRoot(int x)if(Treex=-1)return x;elseint tmp=findRoot(Treex);Treex=tmp;return tmp;bool Cmp(Edge a,Edge b)return a.costb.cost;int main()int n;int m;int i;while(scanf(%d,&n)!=EOF)scanf(%d,&m);for(i=1;i=m;i+)scanf(%d%d%d,&Ei.a,&Ei.b,&Ei.cost);sort(E+1,

21、E+1+m,Cmp);/排序for(i=1;i=n;i+)Treei=-1;int ans=0;for(i=1;i=m;i+)int a=findRoot(Ei.a);int b=findRoot(Ei.b);if(a!=b)Treea=b;ans+=Ei.cost;printf(%dn,ans);return 0;*编译原理Principles of Compiler Description After learnt the Principles of Compiler,partychen thought that he can solve a simple expression probl

22、em.So he give you strings of less than 100 characters which strictly adhere to the following grammar (given in EBNF): A:= ( B)|x. B:=AC. C:=+A.Can you solve them too? Input The first line of input gives the number of cases, N(1 N 100). N test cases follow.The next N lines will each contain a string

23、as described above. Output For each test case,if the expression is adapt to the EBNF above output “Good”,else output “Bad”. Sample Input 3(x)(x+(x+x)()(x) Sample Output GoodGoodBad #include #include #include #include #include #include #include #include #include #include #include using namespace std;

24、char ex110;int index;bool A();bool B();bool C();bool A() if(exindex=x) index+; while(exindex= ) index+; return true; if(exindex=() index+; while(exindex= ) index+; if(B()&exindex=) index+; while(exindex= ) index+; return true; return false;bool B() return A()&C();bool C() while(exindex=+) index+; wh

25、ile(exindex= ) index+; /return A(); if (!A() return false; return true;int main() int N; scanf(%d,&N); getchar(); while(N-) gets(ex); index=0; printf(%sn,A()&exindex=0?Good:Bad); return 0;*分开连接Separate Connections Description Partychen are analyzing a communications network with at most 18 nodes. Ch

26、aracter in a matrix i,j (i,j both 0-based,as matrixij) denotes whether nodes i and j can communicate (Y for yes, N for no). Assuming a node cannot communicate with two nodes at once, return the maximum number of nodes that can communicate simultaneously. If node i is communicating with node j then n

27、ode j is communicating with node i. Input The first line of input gives the number of cases, N(1 N 100). N test cases follow.In each test case,the first line is the number of nodes M(1 M 18),then there are a grid by M*M describled the matrix. Output For each test case , output the maximum number of

28、nodes that can communicate simultaneously Sample Input 25NYYYYYNNNNYNNNNYNNNNYNNNN5NYYYYYNNNNYNNNYYNNNYYNYYN Sample Output 24HintThe first test case: All communications must occur with node 0. Since node 0 can only communicate with 1 node at a time, the output value is 2.The second test case: In this setup, we can let node 0 communicate with node 1, and node 3 communicate with node 4. #include #i

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1