




已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
浙江工业大学计算机专业课程统考 第 1 页 C 程序设计 I 课程 上机考试 3 小时 A Have Fun 编程显示 This is Programming Exam Have fun 注意 句首无空格 行末有回车 本题无输入与输出描述 亦无样本输入与输出 B 童谣 问题描述 洋枪打老虎 老虎吃小孩 小孩抱公鸡 公鸡啄蜜蜂 蜜蜂蛰瘌痢 瘌痢背洋枪 洋枪打老虎 老虎吃小孩 这是孩提时代的童谣 它还可以变化出很多种好玩的游戏呢 可是 今天我们都长大了 淡忘了过去的那些事 显然 该童谣的特征是诵呀诵 循环往复永远诵不完 当老邻居昨天突然在我面前挤 出 洋枪打老虎 这些字眼的时候 我马上就想好好地回忆往事 可是 我们都老了 连 完整的童谣都想不起来了 好在现在的科学技术发达了 可以用计算机来帮助我们快速 回忆 那童谣的每一个 词句了 请乐助的你编个程序来帮助我们吧 输入描述 输入数据包含一些空格或回车间隔的整数 n n6 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 InputInput 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 OutputOutput 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 SampleSample InputInput 7 1 2 3 4 5 6 7 8 1 2 3 5 8 13 21 34 0 浙江工业大学计算机专业课程统考 第 3 页 SampleSample OutputOutput 1 2 3 4 5 6 1 2 3 4 5 7 1 2 3 4 6 7 1 2 3 5 6 7 1 2 4 5 6 7 1 3 4 5 6 7 2 3 4 5 6 7 1 2 3 5 8 13 1 2 3 5 8 21 1 2 3 5 8 34 1 2 3 5 13 21 1 2 3 5 13 34 1 2 3 5 21 34 1 2 3 8 13 21 1 2 3 8 13 34 1 2 3 8 21 34 1 2 3 13 21 34 1 2 5 8 13 21 1 2 5 8 13 34 1 2 5 8 21 34 1 2 5 13 21 34 1 2 8 13 21 34 1 3 5 8 13 21 1 3 5 8 13 34 1 3 5 8 21 34 1 3 5 13 21 34 1 3 8 13 21 34 1 5 8 13 21 34 2 3 5 8 13 21 2 3 5 8 13 34 2 3 5 8 21 34 2 3 5 13 21 34 2 3 8 13 21 34 2 5 8 13 21 34 3 5 8 13 21 34 D Box of Bricks DescriptionDescription Little Bob likes playing with his box of bricks He puts the bricks one upon another and builds stacks of different height Look I ve built a wall he tells his older sister Alice Nah you should make all stacks the same height Then you would have a real wall she retorts After a little consideration Bob sees that she is right So he sets out to rearrange the bricks one by one such that all stacks are the same height afterwards But since Bob is lazy he wants to do this with the minimum number of bricks moved Can you help 浙江工业大学计算机专业课程统考 第 4 页 InputInput The input consists of several data sets Each set begins with a line containing the number n of stacks Bob has built The next line contains n numbers the heights hi of the n stacks You may assume 1 n 50 and 1 hi 100 The total number of bricks will be divisible by the number of stacks Thus it is always possible to rearrange the bricks such that all stacks have the same height The input is terminated by a set starting with n 0 This set should not be processed OutputOutput For each set print the minimum number of bricks that have to be moved in order to make all the stacks the same height Output a blank line between each set SampleSample InputInput 6 5 2 4 1 7 5 0 SampleSample OutputOutput 5 E 剪花布条 基本描述 一块花布条 里面有些图案 另有一块直接可用的小饰条 里面也有一些图案 对于 给定的花布条和小饰条 计算一下能从花布条中尽可能剪出几块小饰条来呢 输入描述 输入中含有一些数据 分别是成对出现的花布条和小饰条 其布条都是用可见 ASCII 字符表示的 可见的 ASCII 字符有多少个 布条的花纹也有多少种花样 花纹条和小饰条 不会超过 1000 个字符长 如果遇见 字符 则不再进行工作 浙江工业大学计算机专业课程统考 第 5 页 输出描述 输出能从花纹布中剪出的最多小饰条个数 如果一块都没有 那就老老实实输出 0 每个结果之间应换行 样本输入 abcde a3 aaaaaa aa 样本输出 0 3 F 内码对称 基本描述 C 中 int 型整数内码是一个 32 位的 01 序列 该 01 序列有些是对称的 有些是不对 称的 对于给定的一个整数 在一些场合 需要判断其整数内码的对称性 这个事情要做 好还非你不行呢 输入描述 输入中含有一些整数 n 0 n 232 输出描述 统计其中一共有多少个其内码对称的整数 输出之 样本输入 0 1 2147483649 2 3 样本输出 2 G 最短空间两点 基本描述 给定一些空间上的点 求出彼此距离最近的两点 输入描述 浙江工业大学计算机专业课程统考 第 6 页 输入数据中含有一些数据组 数量 100 每组数据由一个整数 n 2 n 102 领衔 后跟 n 个空间坐标点 x y z 10000 整数 x y z 10000 若 n 0 则表示输入结束 输出描述 每组数据都有彼此距离最短的坐标点 输出所有彼此距离最短的两点坐标 用括号将 其括起来 坐标点之间空一格 坐标点的输出总是按 x y z 的大小次序 若有多对最短距离 点 则换行输出 并且多对坐标点的输出顺序也按 x y z 的大小次序 每组数据的结果之间 空一行 所谓 x y z 的大小次序 就是先比较 x 的大小 再比较 y 的大小 最后比较 z 的大小 样本输入 4 1 2 3 0 0 0 3 6 0 7 2 0 3 1 3 1 3 1 0 0 0 0 11 1 2 0 2 3 0 3 5 0 7 5 0 9 6 0 9 7 1 10 8 1 1 9 1 9 1 1 10 11 2 10 12 2 0 样本输出 0 0 0 1 2 3 1 3 1 3 1 0 10 11 2 10 12 2 H 核反应堆 问题描述 某核反应堆有两类事件发生 高能质点碰击核子时 质点被吸收 放出 3 个高能质点和 1 个低能质点 低能质点碰击核子时 质点被吸收 放出 2 个高能质点和 1 个低能质点 浙江工业大学计算机专业课程统考 第 7 页 假定开始的时候 0 微秒 只有一个高能质点射入核反应堆 每一微秒引起一个事件 发生 试确定 n 微秒时高能质点和低能质点的数目 输入描述 输入含有一些整数 n 0 n 33 以微秒为单位 若 n 为 1 表示处理结束 输出描述 分别输出 n 微秒时刻高能质点和低能质点的数量 高能质点与低能质点数量之间以逗 号空格分隔 每个输出之间空一行 样本输入 5 2 1 样本输出 11 4 571 209 提示 可以使用 long long int 对付 GNU C 使用 int64 对付 VC6 用流进行输入 输出 I 另类二进制数 基本描述 当我们要用十进制数表达二进制数的时候 使用如下的实例转换 100112 1 24 0 23 0 22 1 21 1 20 16 0 0 2 1 19 可是 有一种另类的二进制数 虽然也是逢 2 进位 但其允许各位上其中有一个可以 是 2 其成数的规则暂且不论 它到十进制数的转换却以如下的实例说明 101202 1 25 1 0 24 1 1 23 1 2 22 1 0 21 1 31 0 7 6 0 44 该另类二进制数的前 10 个数为 0 1 2 10 11 12 20 100 101 102 显然与 3 进制数不 同 它的增 1 操作是以先消去存在的 2 为前提的 即将 2 变成 0 而直接进位 若所有的 位都是 0 或 1 它才从个位开始增值 因此 这种数的操作优点是 加 1 时最多只有一次 进位 因而在某些应用上很有用 你的任务是编程将另类二进制数转换成十进制数 浙江工业大学计算机专业课程统考 第 8 页 输入描述 输入数据中有一些行 每行中有一个数 位长 31 若为 0 则表示输入结束 否则 就表示非负的另类二进制数 输出描述 对于每个另类二进制数 输出其等价的十进制数 其十进制数最大不会超过 231 1 样本输入 10120 200000000000000000000000000000 10 1000000000000000000000000000000 11 100 11111000001110000101101102000 0 样本输出 44 2147483646 3 2147483647 4 7 1041110737 答案答案 1 Have Fun include using namespace std int main cout This is Programming Exam Have fun n 2 童谣 include using namespace std int main 浙江工业大学计算机专业课程统考 第 9 页 char a 6 洋枪打老虎 老虎吃小孩 小孩抱公鸡 公鸡啄蜜蜂 蜜蜂蛰瘌痢 瘌痢背洋枪 for int n cin n cout a n 1 6 n 3 Lotto include include using namespace std int main for int n m 0 cin n cout m n vector v n for int i 0 i v i for int a 0 a n 5 a for int b a 1 b n 4 b for int c b 1 c n 3 c for int d c 1 d n 2 d for int e d 1 e n 1 e for int f e 1 f n f cout v a v b v c v d v e v f n 4 Box of Bricks include include using namespace std int main for int n j 0 cin n int avg 0 moves 0 vector box n for int i 0 i box i i avg box i avg n for int i 0 ibox i avg box i 0 cout j n moves n 浙江工业大学计算机专业课程统考 第 10 页 5 剪花纹布 include include using namespace std int main for string s t cin s cin t int n 0 for int p s find t p string npos p s find t p t length n cout n n 6 内码对称 include using namespace std bool isSym unsigned a for int i 0 i i return true int main int num 0 for unsigned a cin a num isSym a cout num n 7 彼此最近两点 include include include using namespace std struct Point Point int xa 0 int ya 0 int za 0 x xa y ya
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 建筑企业流动资金借款合同(一)
- 全谷物微胶囊包埋-洞察及研究
- 2025年卡车科目考试题及答案
- 护理核心制度考试试题(含答案)
- 输血护理知识试题及答案
- 民族药研究内容
- 2025年picc相关知识试题及答案详解
- 偏瘫病人康复训练分享
- 林草种子工基础知识考核试卷及答案
- 系统集成方案-洞察及研究
- 学校“1530”安全教育记录表(2024年秋季全学期)
- 讲义经尿道前列腺电切术
- 宫颈锥切日间手术临床路径(妇科)及表单
- GB/T 8905-2012六氟化硫电气设备中气体管理和检测导则
- GA/T 1073-2013生物样品血液、尿液中乙醇、甲醇、正丙醇、乙醛、丙酮、异丙醇和正丁醇的顶空-气相色谱检验方法
- 阅兵观后感作文500字范文
- 2023年浙江黄龙体育发展有限公司招聘笔试题库及答案解析
- CMA全套文件(质量手册+程序文件+作业指导书+表格)
- 数控机床(超全)课件
- 医院信息安全与保密承诺书2篇
- 康复护理学-康复评定认知功能评定
评论
0/150
提交评论