当前位置: 首页 > news >正文

手搓文件管理系统(持续开发中)

#include<bits/stdc++.h>
using namespace std;/*** command:* 			cd [dirname]* 				to shift to a name_given dir* 			mkdir [dirname]* 				create a new dir under current dir* 			ls [dirname]* 				list the dir under current dir in specific order* * */int dircnt=1;       //the number of dir
int now=1;          //the dir's ID which you are now
int fa[100010];     //fa for Union-Find
map<string,int>mp;  //give it a name turned out a ID
struct direction{string dirname; //its nameint dep;        //the dep in the dir_treevector<int>son; //its son_dir
}a[100010];         //struct for directionsdeque<int>pos;      // your current path
int pos_size=1;     // the size of pathvoid mkdir(){//"mkdir"string new_name;cin>>new_name;if(mp[new_name]){//SPJ for [under]cout<<"already have this direction!"<<endl;return;}dircnt++;mp[new_name]=dircnt;           //IDfa[ dircnt ] = now;            //son and fathera[now].son.push_back(dircnt);  //contain IDa[dircnt].dep=a[now].dep+1;    //depa[dircnt].dirname=new_name;    //dir_namecout<<"Successfully make a dir named\""<<new_name<<"\""<<endl<<endl;
}int find_dep(int x,int to_dep){if(a[x].dep==to_dep)return x;return find_dep(fa[x],to_dep);
}void change_dir(){//"cd"string to_name;cin>>to_name;if(mp[to_name]==0){//SPJ for [under] invalid casecout<<"you don't have such a direction ,which named \""<<to_name<<"\""<<endl<<endl;return;}int to=mp[to_name],to_dep=a[to].dep;now=to;cout<<"Loading..."<<endl;pos.clear();//as you seepos_size=0;for(int i=1;i<=to_dep;i++){//start from Desktop (time_eff not good(no care))pos.push_back(find_dep(to,i));pos_size++;//dont forget pos_size//cout<<"id:"<<find_dep(to,i)<<"  and dir_name:"<<a[find_dep(to,i)].dirname<<endl;//test [up];}cout<<"Successfully changed to \""<<to_name<<"\""<<endl<<endl;
}void list_dir(int now){//"ls"}void init_system(){//as you seefor(int i=0;i<=100009;i++)fa[i]=i;    //Union-findmp["Desktop"]=1;        //desk_ida[1].dirname="Desktop"; //desk_namea[1].dep=1;             //desk_dep  now=1;                  //cur_pospos.push_back(1);       //cur_pathcout<<endl;             cout<<"<Desktop>:";
}void print_path(){cout<<"<";for(int i=1;i<=pos_size;i++){cout<<a[pos.front()].dirname;pos.push_back(pos.front());  pos.pop_front();if(i!=pos_size)cout<<" / ";  //SPJ//using a deque to turn it aside to output//your current path}cout<<">: ";
}int main(){init_system();while(1){string tmp;cin>>tmp;if(isdigit(tmp[0])){cout<<tmp<<endl;print_path();}if(!isdigit(tmp[0])){if(tmp=="mkdir"){mkdir();print_path();continue;}if(tmp=="cd"){change_dir();print_path();continue;}if(tmp=="ls"){list_dir(now);print_path();continue;}if(tmp=="shut"){cout<<endl<<"Shut down the system successfully!"<<endl;cout<<"Have a good day!"<<endl;exit(0);}print_path();}}return 0;
}
/*** g++ a.cxx* ./a.out* * **/
http://www.rkmt.cn/news/26677.html

相关文章:

  • AGC001~030 合集
  • AGC 合集 1.0
  • 深入BERT内核:用数学解密掩码语言模型的工作原理
  • [论文笔记] Precision-Guided Context Sensitivity for Pointer Analysis
  • 朋友圈文案不会写?这个AI指令可能帮得上忙
  • 职责分离的艺术:剖析主从Reactor模型如何实现极致的并发性能
  • 数学题刷题记录(数学、数论、组合数学)
  • 记录一次raid恢复之后数据库故障处理(ora-01200,ORA-26101,ORA-600)---惜分飞
  • 深入认识ClassLoader - 一次投产失败的复盘
  • 软件工程第三次作业-结对作业
  • 2025年线路调压器厂家推荐榜:10kv线路调压器/单相线路调压器/三相线路调压器/助力电网稳定运行,优选品牌指南
  • 2025 智能/商超照明/灯具/灯光/源头厂家推荐榜:上海富明阳凭分区域光效领跑,生鲜 / 百货场景适配优选
  • 2025 变电站厂家推荐榜最新资讯:撬装变电站/移动车载变电站/预制舱式变电站/移动变电站/预装式变电站/聚焦智能适配与可靠服务,这家企业成优选​
  • helloworld的输出
  • 2025 艺考文化课推荐榜:济南震华学校 5 星领跑,全阶段体系适配基础补弱到高分冲刺
  • 2025 广州人力资源/派遣/劳务外包/人事代理/推荐榜:精典人才凭派遣合规 + 全场景适配领跑,企业用工优选
  • 读书日记2
  • 深入解析:【Linux】生产者消费者模型
  • 湖南新建高速项目的“神经网络”是如何搭建的?——揭秘80公里高速的收费、通信、监控一体化系统
  • 深入解析:大数据Spark(六十六):Transformation转换算子sample、sortBy和sortByKey
  • 完整教程:web前端团队开发code review方案最佳实践
  • 最大值的不同统计方法
  • 加密货币如何改变金融诈骗的游戏规则
  • java的字符和字符串
  • python_日志记录-loguru
  • 2025年流量计厂家权威推荐榜单:电磁流量计、超声波流量计、涡街流量计、质量流量计专业制造商深度解析
  • day03-Coze记忆-对话体验
  • 2025年印染水洗机厂家权威推荐榜:高效水洗设备与环保节能技术深度解析,专业水洗机厂家精选
  • 2025年角接触轴承厂家推荐排行榜,高精度/高承载/高精密/机床主轴/汽车/定制/可替代进口/高转速/高刚性角接触球轴承公司推荐
  • datadome 二维数组