# POJ 1057 FILE MAPPING

1. 这道题根本不会做，直接看的别人的解体报告，看了别人的解题报告的算法说明，还是不会做，只好看代码了；

2. 这篇博客写得比我写得好（http://jovesky.info/blog/2011/08/12/poj-1057-file-mapping-c-edition/），我就是看人家的看懂的；

3. 递归+vector，一层套一层，以后还得看看怎么做的。现在思路会了，但是vector还是不会用，上午刚看了primer还是不会用，另外细节问题很繁琐，日后就是为了学递归也得再做一遍这道题。

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

struct node
{
vector<string> file;
vector<node> dir;
string name;
};
int end = 0;
void fileinput(node &now)
{
string tmp;
while (1)
{
cin >> tmp;
if (tmp[0] == '#')
{
end = 1;
break;
}
else if (tmp[0] == 'f')
now.file.push_back(tmp);
else if (tmp[0] == 'd')
{
node d;
d.name = tmp;
fileinput(d);
now.dir.push_back(d);
}
else break;
}
sort(now.file.begin(), now.file.begin() + now.file.size());
return;
}

void fileoutput(node now, int n)
{
int i, j;
for (i = 0; i < n; i++)
cout << "|     ";
cout << now.name << endl;
for (i = 0; i < (int)now.dir.size(); i++)
fileoutput(now.dir[i], n + 1);
for (i = 0; i < (int)now.file.size(); i++)
{
for (j = 0; j < n; j++)
cout << "|     ";
cout << now.file[i] << endl;
}
return;
}

int main()
{
int cases = 1;
while (cases)
{
node root;
root.name = "ROOT";
fileinput(root);
if (end)
break;
cout << "DATA SET " << cases << ':' << endl;
fileoutput(root, 0);
cases++;
cout << endl;
}
return 0;
}

#### ［递归］poj 1057 FILE MAPPING

2016-06-03 14:39:37

#### POJ 1057 FILE MAPPING(文件结构图)

2016-11-13 01:09:54

#### poj 1057-File mapping

2015-04-26 19:33:57

#### poj 1057 FILE MAPPING(递归)

2017-09-11 14:24:25

#### POJ 1057 FILE MAPPING 笔记

2017-05-09 07:16:46

#### hdu 1057 A New Growth Industry

2012-11-21 17:15:03

#### 【poj1057】FILE MAPPING 模拟

2016-07-14 02:19:23

#### No mapping found for HTTP request with URI [/Springmvc/test] in DispatcherServlet with dispatche

2018-05-30 20:05:16

#### PAT甲级1057

2017-02-08 20:02:25

#### windows注册服务，“1057：账户名无效或不存在”错误

2015-03-14 15:14:35