论文部分内容阅读
这道题来源于第三届国际信息学奥林匹克的第二轮试题,有相当难度。作这道题必须掌握递归思想和递归算法,要对指针、记录、二叉树、字符序列的生成与处理等许多问题进行深入研究和灵活运用。 一、递归生成s项 设项中s的数目为n,依题意 当n=1时,只有一个字符串,即S。 当n=2时,也只有一个字符串,即(SS)。 当n=3时,有2个字符串,即(S(SS));((SS)S)。 当n=4时,有5个字符串,即(((SS)S)S);((S(SS))S);((SS)(SS));(S((SS)S));(S(S(SS)))。
This problem stems from the third round of the second International Informatics Olympiad questions, quite difficult. For this problem, we must master the recursive thinking and the recursive algorithm. We must conduct in-depth research and make flexible use of many problems such as pointers, records, binary trees, generation and processing of character sequences. First, the recursive generation of s items in the number of s n, according to the idea that when n = 1, only one string, that is, S. When n = 2, there is only one string, that is, (SS). When n = 3, there are 2 strings, namely (S (SS)); ((SS) S). When n = 4, there are 5 strings, that is, (((SS) S) S); (S (SS)) S) ); (S (S (SS))).