C # is fun, even the first decent C # program

xiaoxiao2021-03-06  41

C # is fun, use pascal to use this simply comfortable death, vs.net and turbo pascal are definitely not a level. Pascal is not object-oriented, makes us want to make a tree to determine Record and put it in an array, C # can directly point directly, and it itself is an object. Doesn't need a weird number of groups ... speed, no care, but it is a transient. Oh. Even the first program is HelloWorld, this, Is the first decent program ... um, no waste

FBI tree (FBI.PAS / DPR / C / CPP)

【Problem Description】

We can divide the strings consisting of "0" and "1" into three categories: full "0" is called B string, "1" is called the i string, including "0" and "1" The string is called a F string. The FBI tree is a bifurcous tree [1], its node type also includes three of the F node, B node and i nodes. A "01" string S which can be constructed from a length of 2 N may construct a FBI tree T, the recurrent constructor is as follows: 1) T, the root node is R, which is the same as the type S of S, 2) If the string S The length is greater than 1, separate the string S from the middle, divided into equal length left and right substrings S1 and S2; the left sub-tree T1 of R is constructed from the left sub-string S1, and the right sub-tree T2 is constructed by the right subtrive S2. Now give a "01" string of a length of 2N, a FBI tree is constructed by the above construction method, and outputs its rear sequence [2] sequence.

[Enter file]

The first line of input file fbi.in is an integer N (0 <= n <= 10), and the second line is a "01" string of length 2n.

[Output File]

Output files FBI.out include a line, this line contains only a string, namely the back sequence of the FBI tree.

[Sample input]

310001111

[Sample output]

Ibfbbbfibfiiiff

[Data size]

For 40% of data, n <= 2; for all data, n <= 10.

[1] Binary tree: binary tree is a limited set of nodes, this collection or empty set, or consists of a root node and two non-intersecting binary trees. The two non-intersecting bifurches are called the left subtilion and the right subtree of this root point, respectively.

[2] Back sequence traversal: The sequence traversal is a method of depth priority to traversing the binary tree. Its recursive definition is: the first sequence traverses the left subtree, and then traverse the right tree, and finally access the root.

转载请注明原文地址:https://www.9cbs.com/read-59349.html

New Post(0)