[HRBUST - 1371] 대 시 뮬 레이 션.

간단 한 시 뮬 레이 션 을 알 아 보지 못 하 다 니, 나 는 너무 형편없다.
제목: Leyni OS HRBUST - 1371
링크:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1371
제목:
모두 두 가지 조작 이 있다.pwd 인쇄 경로, 두 번 째 cd + 경로, 기 존 경 로 를 변경 합 니 다. (경로 형식 주의)
문제 풀이:
시 뮬 레이 션
  • /x/y/z
  • /x/y/z/
  • x/y/z
  • x/y/z/
  • #include 
    #include 
    #include 
    using namespace std;
    struct node{
        string s;
    }s[2000];//4000   
    void init(){//   
        for(int i=0;i<2000;i++){
            s[i].s="";
        }
    }
    int main(){
        int T;
        scanf("%d",&T);
        while(T--){
            int N,cnt=0;
            scanf("%d",&N);
            init();
            while(N--){
                string oper;
                cin>>oper;
                if(oper=="pwd"){
                    for(int i=0;i>t;
                    /* *
                     *   :
                     * /x/x             
                     * x/x/    /x/x/        
                     * */
                    if(t[t.length()-1]=='/'){
                        init();cnt=0;
                        continue;
                    }
                    else t+="/";
                    if(t[0]=='/'){
                        init();cnt=0;
                    }
                    else{
                        t='/'+t;
                    }
                    //          /x/y/z/,      
                    for(int i=0;i

    좋은 웹페이지 즐겨찾기