随笔分类 -  递归

摘要:B01:篮球联赛 描述 校篮球队每年都会举办“年级联赛”。篮球队的队员们将根据年级分为一年级、二年级、三年级和四年级4支队伍,参与角逐。 在年级联赛中,不同队伍两两之间比赛一场,胜者积1分,负者积0分(篮球比赛无平局)。最终队伍将按照积分从高到低排名,若出现同分,则年级较低的排名靠前。 现在年级联赛 阅读全文
posted @ 2018-06-25 15:51 TobicYAL 阅读(1155) 评论(0) 推荐(0)
摘要:描述 考虑一段DNA单链,上面有N个基因片段。这里的基因片段可重叠(例如AGCTC包含AGC和CTC),不可倒置(例如AGCTC不包含TCG)。要问这样的单链最短长度是多少。 输入 输入的第一行是一个正整数T(不超过13),表示数据组数。每组数据若干行,其中第一行一个正整数N(不超过9),表示基因片 阅读全文
posted @ 2018-06-03 11:04 TobicYAL 阅读(1271) 评论(0) 推荐(2)
摘要:A:Boolean Expressions 描述The objective of the program you are going to produce is to evaluate boolean expressions as the one shown next: where V is for 阅读全文
posted @ 2018-05-14 21:32 TobicYAL 阅读(501) 评论(0) 推荐(0)
摘要:背景 给定一个正整数序列a(1),a(2),...,a(n),(1<=n<=20)不改变序列中每个元素在序列中的位置,把它们相加,并用括号记每次加法所得的和,称为中间和。 例如:给出序列是4,1,2,3。 第一种添括号方法:((4+1)+(2+3))=((5)+(5))=(10)有三个中间和是5,5 阅读全文
posted @ 2018-03-13 23:14 TobicYAL 阅读(392) 评论(0) 推荐(0)
摘要:题目描述 Description 求一棵二叉树的前序遍历,中序遍历和后序遍历 题目描述 Description 求一棵二叉树的前序遍历,中序遍历和后序遍历 求一棵二叉树的前序遍历,中序遍历和后序遍历 输入描述 Input Description 第一行一个整数n,表示这棵树的节点个数。 接下来n行每 阅读全文
posted @ 2018-02-26 10:06 TobicYAL 阅读(247) 评论(0) 推荐(0)
摘要:题目描述 Description 给出一个二叉树,输出它的最大宽度和高度。 题目描述 Description 给出一个二叉树,输出它的最大宽度和高度。 给出一个二叉树,输出它的最大宽度和高度。 输入描述 Input Description 第一行一个整数n。 下面n行每行有两个数,对于第i行的两个数 阅读全文
posted @ 2018-02-14 16:59 TobicYAL 阅读(253) 评论(0) 推荐(0)
摘要:取石子问题 1 #include "stdlib.h" 2 #include <iostream> 3 #include<string> 4 #include <stdio.h> 5 using namespace std; 6 int step=0;//设定走的步数为step 7 int getm 阅读全文
posted @ 2017-12-22 22:03 TobicYAL 阅读(662) 评论(0) 推荐(0)
摘要:布尔表达式 #include <iostream> #include <string.h> #include <memory> using namespace std; char str[1500], equ[1500]; char sign[1000]; int num[1000]; int s 阅读全文
posted @ 2017-12-10 19:48 TobicYAL 阅读(628) 评论(0) 推荐(0)
摘要:习题(15-1) 前缀表达式 (1010) 1 #include <iostream> 2 #include<cstring> 3 using namespace std; 4 char str[100][20]; //定义一个字符数组,以空格为界,每行存放一个符号或数 5 int strcount 阅读全文
posted @ 2017-11-26 14:51 TobicYAL 阅读(823) 评论(0) 推荐(0)
摘要:1 #include <iostream> 2 using namespace std; 3 int queen[9],qcount=0; 4 void print() 5 { 6 for(int i=1;i<9;i++) 7 { 8 if (queen[i] == 1) 9 cout << "*" 阅读全文
posted @ 2017-11-16 21:10 TobicYAL 阅读(499) 评论(0) 推荐(0)
摘要:1 #include <iostream> 2 #include<string.h> 3 using namespace std; 4 int f(int i,char a,char b,char c) //定义一个函数为i个圆盘从a经过b全部套到a上的函数 5 { 6 if (i == 1) // 阅读全文
posted @ 2017-11-09 20:34 TobicYAL 阅读(387) 评论(0) 推荐(0)