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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

C语言练习题.docx

1、C语言练习题Problem A: boy and grilTime Limit:1 SecMemory Limit:128 MBSubmit:7Solved:3SubmitStatusWeb BoardDescriptionDuring the break the schoolchildren, boys and girls, formed a queue ofnpeople in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the

2、 boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward each second.Lets describe the process more precisely. Lets say that the positions in the queue are sequentially numbered by integers from1ton, at that the person in the posit

3、ion number1is served first. Then, if at timexa boy stands on thei-th position and a girl stands on the(i+1)-th position, then at timex+1thei-th position will have a girl and the(i+1)-th position will have a boy. The time is given in seconds.Youve got the initial position of the children, at the init

4、ial moment of time. Determine the way the queue is going to look aftertseconds.InputThe first line contains two integersnandt(1n,t50), which represent the number of children in the queue and the time after which the queue will transform into the arrangement you need to find.The next line contains st

5、rings, which represents the schoolchildrens initial arrangement. If thei-th position inthe queue contains a boy, then thei-th character of stringsequals B, otherwise thei-th character equals G.OutputPrint stringa, which describes the arrangement aftertseconds. If thei-th position has a boy after the

6、 needed time, then thei-th characteramust equal B, otherwise it must equal G.Sample Input5 1BGGBGSample OutputGBGGBProblem B: WordTime Limit:1 SecMemory Limit:128 MBSubmit:27Solved:7SubmitStatusWeb BoardDescriptionVasya is very upset that many people on the Net mix uppercase and lowercase letters in

7、 one word. Thats why he decided to invent an extension for his favorite browser that would change the letters register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At that as little as possible letters should be changed in the word. For

8、example, the word HoUse must be replaced with house, and the word ViP with VIP. If a word contains an equal number of uppercase and lowercase letters, you should replace all the letters with lowercase ones. For example, maTRIx should be replaced by matrix. Your task is to use the given method on one

9、 given word.InputThe first line contains a word s it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100.OutputPrint the corrected word s. If the given word s has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the

10、 lowercase one.Sample InputHoUseSample OutputhouseProblem C: TeamTime Limit:1 SecMemory Limit:128 MBSubmit:3Solved:3SubmitStatusWeb BoardDescriptionOne day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several

11、 problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends wont write the problems solution.This contest offersnproblems to the participants. For each problem we know,

12、 which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.InputThe first input line contains a single integern(1n1000) the number of problems in the contest. Thennlines contain three integers each, each integer is either0or1. If the f

13、irst number in the line equals1, then Petya is sure about the problems solution, otherwise he isnt sure. The second number shows Vasyas view on the solution, the third number shows Tonyas view. The numbers on the lines are separated by spaces.OutputPrint a single integer the number of problems the f

14、riends will implement on the contest.Sample Input31 1 01 1 11 0 0Sample Output2Problem D: 神、上帝以及老天爷Time Limit:1 SecMemory Limit:128 MBSubmit:27Solved:8SubmitStatusWeb BoardDescriptionHDU 200610 ACM contest的颁奖晚会隆重开始了!为了活跃气氛,组织者举行了一个别开生面、奖品丰厚的抽奖活动,这个活动的具体要求是这样的:首先,所有参加晚会的人员都将一张写有自己名字的字条放入抽奖箱中;然后,待所有字条

15、加入完毕,每人从箱中取一个字条;最后,如果取得的字条上写的就是自己的名字,那么“恭喜你,中奖了!”大家可以想象一下当时的气氛之热烈,毕竟中奖者的奖品是大家梦寐以求的Twins签名照呀!不过,正如所有试图设计的喜剧往往以悲剧结尾,这次抽奖活动最后竟然没有一个人中奖!我的神、上帝以及老天爷呀,怎么会这样呢?不过,先不要激动,现在问题来了,你能计算一下发生这种情况的概率吗?不会算?难道你也想以悲剧结尾?!Input输入数据的第一行是一个整数C,表示测试实例的个数,然后是C行数据,每行包含一个整数n(1n=20),表示参加抽奖的人数。Output对于每个测试实例,请输出发生这种情况的百分比,每个实例的

16、输出占一行,结果保留两位小数(四舍五入),具体格式请参照sample output。Sample Input12Sample Output50.00%HINTProblem E: 前m大的数Time Limit:1 SecMemory Limit:128 MBSubmit:16Solved:9SubmitStatusWeb BoardDescription还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大的M个数告诉她就可以了。给定一个包含N(N=3000)个正

17、整数的序列,每个数不超过5000,对它们两两相加得到的N*(N-1)/2个和,求出其中前M大的数(M=N*(N-1)/2)并按从大到小的顺序排列。Input输入可能包含多组数据,其中每组数据包括两行:第一行两个数N和M,第二行N个数,表示该序列。Output对于输入的每组数据,输出M个数,表示结果。输出应当按照从大到小的顺序排列。Sample Input4 41 2 3 44 55 3 6 4Sample Output7 6 5 511 10 9 9 8HINTProblem F: sh崽 OrOrOrOrzTime Limit:1 SecMemory Limit:128 MBSubmit:3

18、Solved:3SubmitStatusWeb BoardDescriptionAcmer in HDU-ACM team are ambitious, especially sh崽, he can spend time in Internet bar doing problems overnight. So many girls want to meet and Orz him. But Orz him is not that easy.You must solve this problem first.The problem is :Give you a sequence of disti

19、nct integers, choose numbers as following : first choose the biggest, then smallest, then second biggest, second smallest etc. Until all the numbers was chosen .For example, give you 1 2 3 4 5, you should output 5 1 4 2 3在hdu-acm团队ACMer野心勃勃,尤其是SH崽,InputThere are multiple test cases, each case begins

20、 with one integer N(1 = N = 10000), following N distinct integers.OutputOutput a sequence of distinct integers described above.Sample Input51 2 3 4 5Sample Output5 1 4 2 3HINTProblem G: A + B Problem IITime Limit:1 SecMemory Limit:33 MBSubmit:4Solved:1SubmitStatusWeb BoardDescriptionGiven two intege

21、rs A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1=T=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large. You may assume the length of

22、each integer will not exceed 2000.OutputFor each test case, you should output two lines. The first line is Case #:, # means the number of the test case. The second line is the an equation A + B = Sum, Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line bet

23、ween two test cases.Sample Input21 2112233445566778899 998877665544332211Sample OutputCase 1:1 + 2 = 3Case 2:112233445566778899 + 998877665544332211 = 111111*1110HINTProblem H: Eddys research ITime Limit:1 SecMemory Limit:33 MBSubmit:3Solved:2SubmitStatusWeb BoardDescriptionEddys interest is very ex

24、tensive, recently he is interested in prime number. Eddy discover the all number owned can be divided into the multiply of prime number, but he cant write program, so Eddy has to ask intelligent you to help him, he asks you to write a program which can do the number to divided into the multiply of p

25、rime number factor .InputThe input will contain a number 1 x= 3, f(n) = f(n - 1) + f(n - 2).它的前几项可以表示为 1, 1, 2, 3, 5, 8, 13, 21, 34 ., 问 f(n) 的值是否能被 3 和 4 整除.Input输入数据有若干组, 每组数据包含一个整数 n , (1 n = 1 000 000 000).Output对于每组数据 n, 如若 f(n)能被 12 整除则输出 “YES”, 否则如若能被 3 整除则输出 “3”; 能被 4 整除则输出 “4”,若都不满足否则输出 “NO”.Sample Input467Sample Output34NO

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

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