- 1、本文档共12页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C程序设计试卷1
《C++程序设计I》课程
上机考试 (3小时)
A. Have Fun
编程显示:
This is Programming Exam. Have fun.
注意:句首无空格,行末有回车。
本题无输入与输出描述,亦无样本输入与输出
B. 童谣
问题描述
“洋枪打老虎,老虎吃小孩,小孩抱公鸡,公鸡啄蜜蜂,蜜蜂蛰瘌痢,瘌痢背洋枪,洋枪打老虎,老虎吃小孩…”,这是孩提时代的童谣,它还可以变化出很多种好玩的游戏呢。可是,今天我们都长大了,淡忘了过去的那些事。
显然,该童谣的特征是诵呀诵,循环往复永远诵不完。当老邻居昨天突然在我面前挤出“洋枪打老虎”这些字眼的时候,我马上就想好好地回忆往事,可是,我们都老了,连完整的童谣都想不起来了。
好在现在的科学技术发达了,可以用计算机来帮助我们快速“回忆”那童谣的每一个词句了,请乐助的你编个程序来帮助我们吧。
输入描述
输入数据包含一些空格或回车间隔的整数n(n232),表示从“洋枪打老虎”开始的句序。若n等于0,则表示停止“回忆”。
输出描述
对每个整数n,输出从“洋枪打老虎”开始诵起的第n句童谣词,每句词之间应换行。
样本输入
2 9
6 3 0
样本输出
老虎吃小孩
小孩抱公鸡
瘌痢背洋枪
小孩抱公鸡
C. Lotto
Description
In the German Lotto you have to select 6 numbers from the set {1,2,...,49}.
A popular strategy to play Lotto - although it doesnt increase your chance of winning - is to select a subset S containing k (k6) of these 49 numbers, and then play several games with choosing numbers only from S.
For example, for k=8 and S = 1,2,3,5,8,13,21,34 there are 28 possible games: [1,2,3,5,8,13], [1,2,3,5,8,21], [1,2,3,5,8,34], [1,2,3,5,13,21], ..., [3,5,8,13,21,34].
Your job is to write a program that reads in the number k and the set S and then prints all possible games choosing numbers only from S.
Input
Input will contain one or more test cases.
Each test case consists of one line containing several integers separated from each other by spaces. The first integer on the line will be the number k (6 k 13). Then k integers, specifying the set S, will follow in ascending order.
Input will be terminated by a value of zero (0) for k.
Output
For each test case, print all possible games, each game on one line.
The numbers of each game have to be sorted in ascending order and separated from each other by exactly one space. The games themselves have to be sorted lexicographically, that means sorted by the lowest number first, then by the second lowest and so on, as demonstrated in the sample output below.
The test cases have to be separated from each other by exactly one blank line. Do not put a blank line after the last test case.
Sample Input
7 1
文档评论(0)