![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
计算机考研_机试指南
肝肠寸段
哈哈哈哈哈哈哈哈嗝~
展开
-
5.3 栈_Zero-complexity Transposition
描述 You are given a sequence of integer numbers. Zero-complexity transposition of the sequence is the reverse of this sequence. Your task is to write a program that prints zero-complexity transposition of the given sequence. 输入 For each case, the first line原创 2021-08-17 20:32:09 · 105 阅读 · 0 评论 -
5.2 队列_猫狗收容所
题目描述 有家动物收容所只收留猫和狗,但有特殊的收养规则。收养人有两种收养方式: 第一种为直接收养所有动物中最早进入收容所的。 第二种为选择收养的动物类型(猫或狗),并收养该种动物中最早进入收容所的。 给定一个操作序列代表所有事件。 若第一个元素为1,则代表有动物进入收容所。第二个元素为动物的编号,正数代表狗,负数代表猫。 若第一个元素为2,则代表有人收养动物。第二个元素若为0,则采取第一种收养方式;若为1,则指定收养狗;若为-1,则指定收养猫。 请按顺序输出收养动物的序列。 若出现不合法的操作,即没有可以原创 2021-08-17 19:54:11 · 307 阅读 · 0 评论 -
5.2 队列 约瑟夫问题
题目描述 n个小孩围坐成一圈,并按顺时针编号为1,2,···,n,从编号为p的小孩顺时针依次报数,由1报到m,报到m时,这名小孩从圈中出去;然后下一名小孩再从1报数,报到m时再出去。以此类推,直到所有小孩都从圈中出去。请按出去的先后顺序输出小孩的编号。 输入 第一个是n,第二个是p,第三个是m(0<m,n<300) 最后一行是:0 0 0 输出 按出圈的顺序输出编号,编号之间以逗号间隔。 样例输入 8 3 4 0 0 0 样例输出 6,2,7,4,3,5,1,8 代码: #include <原创 2021-08-17 12:49:42 · 116 阅读 · 0 评论 -
2.1枚举_习题3 Old Bill
描述 Among grandfather’s papers a bill was found. 72 turkeys $ _ 679 _ .The first and the last digits of the number that obviously represented the total price of those turkeys are replaced here by blanks (denoted _), for they are faded and are illegibl原创 2021-08-17 11:22:10 · 74 阅读 · 0 评论 -
2.1枚举_习题2 百鸡问题
描述 用小于等于n元去买100只鸡,大鸡5元/只,小鸡3元/只,还有1/3元每只的一种小鸡,分别记为x只,y只,z只。编程求解x,y,z所有可能解。 输入描述 测试数据有多组,输入n。 输出描述 对于每组输入,请输出x,y,z所有可行解,按照x,y,z依次增大的顺序输出。 代码: #include <iostream> using namespace std; int main(){ int n; while(cin>>n){ for(int i=0;i<=n/5+原创 2021-08-17 10:55:10 · 91 阅读 · 0 评论 -
2.1枚举_习题1 与7无关的数
描述 一个正整数,如果它能被7整除,或者它的十进制表示法中某个位数上的数字为7, 则称其为与7相关的数.现求所有小于等于n(n<100)的与7无关的正整数的平方和。 输入描述 案例可能有多组。对于每个测试案例输入为一行,正整数n,(n<100) 输出描述 对于每个测试案例输出一行,输出小于等于n的与7无关的正整数的平方和。 代码: #include <iostream> using namespace std; int isSeven(int n){ while(n != 0)原创 2021-08-17 10:43:00 · 198 阅读 · 0 评论 -
2.1 枚举_例题3 对称平方数
描述 打印所有不超过256,其平方具有对称性质的数。如2,11就是这样的数,因为22=4,1111=121。 输入描述 无任何输入数据 输出描述 输出具有题目要求的性质的数。如果输出数据不止一组,各组数据之间以回车隔开。 代码: #include <iostream> using namespace std; int reverse(int m){ int sum = 0; while(m != 0){ sum = sum*10 + m%10; m = m/10; } ret原创 2021-08-17 10:19:45 · 81 阅读 · 0 评论 -
2.1枚举_例题1 abc
描述 设a、b、c均是0到9之间的数字,abc、bcc是两个三位数,且有:abc+bcc=532。求满足条件的所有a、b、c的值。 输入描述 题目没有任何输入。 输出描述 请输出所有满足题目条件的a、b、c的值。 a、b、c之间用空格隔开。 每个输出占一行。 代码: #include <iostream> using namespace std; int main(){ for(int a = 0;a <= 9;a++) for(int b = 0;b <= 9;b++)原创 2021-08-17 09:57:10 · 65 阅读 · 0 评论