解决方案:80分
#include<iostream> #include<iomanip> #include<fstream> #include<string> using namespace std; int main() { char buffer[256] = {0}; string original_path = "e:"; string path_name[5] = {"", "", "", "", ""};//创建一个string数组用来存放每层文件夹的名字,假定最多只有5层 ifstream myfile ("e:\data.txt"); if(!myfile) cout << "Unable to open myfile"; else { while (!myfile.eof()) { string cur_path = "md " + original_path; myfile.getline(buffer,10); string data(buffer); for(int i = 0; i < 10; i++) { if(data[i] != ""\t"") { path_name[i] = data.substr(i); cur_path = cur_path + "\" + path_name[i]; break; } cur_path = cur_path + "\" + path_name[i]; } cout << cur_path << endl; system(cur_path.c_str()); } } system("pause"); }