[Huawei OD Unified Exam B Paper | 200 points] Comment conversion output (C++ Java JavaScript Python)

Huawei OD Online OJ:

Users who have already purchased this column, please private message the blogger to open an account and brush up questions online! ! !

Online OJ: brush the questions immediately

Question bank column: 2023 Huawei OD machine test (A volume + B volume) (C++JavaJSPy)

topic description

On a blogging site, each blog post has comments.

Each comment is a non-empty string of English letters.

Comments have a tree structure, each comment has a parent comment except the root comment.

When a comment is saved, the following format is used:

  • The first is the content of the comment;
  • Then there is the number of replies to the current comment.
  • Finally, all comments for the current comment. (sub-comments are stored nested using the same format)

All elements are separated by a single comma.

For example, if the comment is as follows:

image-20230830223149785

The first comment is "helo,2,ok,0,bye,0", the second comment is "test,0", and the third comment is "one,1,two,1,a,0".

All comments are saved as "hello,2,ok,0.bye,0,test,0,one,1,two,1,a,0".

For comments in the above format, please print in another format

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/132642738