当前位置: 首页 > 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.jsqmd.com/news/18784/

相关文章:

  • AGC001~030 合集
  • 手写体识别
  • AGC 合集 1.0
  • 20231302邱之钊密码系统设计实验一第二
  • 你好,我是肆闲:C语言的学习,成长与分享旅程
  • ZR 2025 NOIP 二十连测 Day 6
  • 20251021
  • [论文笔记] Precision-Guided Context Sensitivity for Pointer Analysis
  • 英语_备忘_疑难
  • 朋友圈文案不会写?这个AI指令可能帮得上忙
  • 「JOISC2020-掃除」题解
  • 职责分离的艺术:剖析主从Reactor模型如何实现极致的并发性能
  • 数学题刷题记录(数学、数论、组合数学)
  • CF简单构造小计
  • 软件工程第三次作业:四则运算题目生成器 - Nyanya-
  • ORA-600 kokasgi1故障处理(sys被重命名)---惜分飞
  • Linux7种文件类型
  • 软件工程第三次作业-结对作业
  • AI代码生成技术解析与应用实践
  • 米理 课程描述/学习计划/Study program
  • 2025年线路调压器厂家推荐榜:10kv线路调压器/单相线路调压器/三相线路调压器/助力电网稳定运行,优选品牌指南
  • 2025 智能/商超照明/灯具/灯光/源头厂家推荐榜:上海富明阳凭分区域光效领跑,生鲜 / 百货场景适配优选
  • 2025 变电站厂家推荐榜最新资讯:撬装变电站/移动车载变电站/预制舱式变电站/移动变电站/预装式变电站/聚焦智能适配与可靠服务,这家企业成优选​
  • 2025 艺考文化课推荐榜:济南震华学校 5 星领跑,全阶段体系适配基础补弱到高分冲刺
  • 完整教程:罗技G102有线鼠标自己维修教程
  • 杂谈
  • 挖矿-学校挖矿排查
  • 读书日记2
  • 定位问题3:明明堆栈已经打印出来了,偏就是定位不出来?
  • Spring 统一机制处理 - 拦截器与适配器