Description
It is often helpful for computer users to see a visual representation of the file structure on their computers. The "explorer" in Microsoft Windows is an example of such a system. Before the days of graphical user interfaces, however, such visual representations were not possible. The best that could be done was to show a static "map"of directories and files, using indentation as a guide to directory contents. For example:
ROOT| DIR1| File1| File2| File3| DIR2| DIR3| File1File1File2
This shows that the root directory contains two files and three subdirectories. The first subdirectory contains 3 files, the second is empty and the third contains one file.
Input
Write a program that reads a series of data sets representing a computer file structure. A data set ends with a line containing a single *, and the end of valid data is denoted by a line containing a single #. The data set contains a series of file and directory names. (The root directory is assumed to be the starting point.) The end of a directory is denoted by a ']' Directory names begin with a lower case 'd' and file names begin with a lower case 'f' File names may or may not have an extension (such as fmyfile.dat or fmyfile). File and directory names may not contain spaces.
Output
Note that the contents of any directory should list any subdirectories first, followed by files, if any. All files should be in alphabetical order within each directory. Note that each data set output is ed by the label "DATA SET x:" where x denotes the number of the set, beginning at 1. Note also the blank line between the output data sets. Each level of indentation should show a '|' followed by 5 spaces.
Sample Input
file1
file2
dir3
dir2
file1
file2
]
]
file4
dir1
]
file3
*
file2
file1
*
#
Sample Output
DATA SET 1:
ROOT
| dir3
| | dir2
| | file1
| | file2
| dir1
file1
file2
file3
file4DATA SET 2:
ROOT
file1
file2
It is often helpful for computer users to see a visual representation of the file structure on their computers. The "explorer" in Microsoft Windows is an example of such a system. Before the days of graphical user interfaces, however, such visual representations were not possible. The best that could be done was to show a static "map"of directories and files, using indentation as a guide to directory contents. For example:
ROOT| DIR1| File1| File2| File3| DIR2| DIR3| File1File1File2
This shows that the root directory contains two files and three subdirectories. The first subdirectory contains 3 files, the second is empty and the third contains one file.
Input
Write a program that reads a series of data sets representing a computer file structure. A data set ends with a line containing a single *, and the end of valid data is denoted by a line containing a single #. The data set contains a series of file and directory names. (The root directory is assumed to be the starting point.) The end of a directory is denoted by a ']' Directory names begin with a lower case 'd' and file names begin with a lower case 'f' File names may or may not have an extension (such as fmyfile.dat or fmyfile). File and directory names may not contain spaces.
Output
Note that the contents of any directory should list any subdirectories first, followed by files, if any. All files should be in alphabetical order within each directory. Note that each data set output is ed by the label "DATA SET x:" where x denotes the number of the set, beginning at 1. Note also the blank line between the output data sets. Each level of indentation should show a '|' followed by 5 spaces.
Sample Input
file1
file2
dir3
dir2
file1
file2
]
]
file4
dir1
]
file3
*
file2
file1
*
#
Sample Output
DATA SET 1:
ROOT
| dir3
| | dir2
| | file1
| | file2
| dir1
file1
file2
file3
file4DATA SET 2:
ROOT
file1
file2
解决方案 »
- <bgsound loop="0" src="flourish.mid"/>怎么用按钮停止播放声音?
- 正则式 http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
- 简单的变量名怎么写
- 今天用jsEclipse写脚本,用紫光拼音V6时崩溃了两次。求在Eclipse平台下稳定的输入法
- 如何判断用户输入的内容里是否包含javascript和html标记
- 百思不得其解(关于一个校验)
- 有一个难度很大的问题,请高手解决。如有一个父窗口,要控制子窗口,但我不知子窗口写有什么javascript代码,我就只想不要这个子窗口中的
- 大家来看看这段代码...........
- jquery,jqgrid,easyui 对象不支持此属性和方法
- "Uncaught TypeError: undefined is not a function"
- 在IE8上运行prompt提示框出不来是咋回事
- iframe浏览器兼容问题
输入:
一个以XXX格式为规则的文件。
输出:
一个树状目录?这种问题,跟用什么解答有啥关系。。说白了就是把特定规则的字符串转化成可直观识别的信息,跟翻译xml、json语句差不多,这个稍微用点时间想下就好了,还需要思路?