1 //stl+ Analog CCF2016 4 Path resolution2 //At First Test instructions understand wrong .... 3 4#include <iostream>5#include <string>6#include <vector>7 using namespacestd;8 voidFre () {freopen ("In.txt","R", stdin);}9vector<string>l;Ten intMain () { One intN; A stringstr; -Cin>>n>>str; - GetChar (); the for(intI=1; i<=n;i++){ - strings; - getline (cin,s); - if(s[0]!='/') s=str+'/'+s; + if(s.size () = =0) s=str; - intPos; + while((Pos=s.find ("//"))!=-1){ A intCount=2; at while(s[pos+count]=='/') count++; -S.erase (pos,count-1); - } - while((Pos=s.find ("/.. /"))!=-1){ - if(pos==0){ -S.erase (pos+1,3); in } - Else{ to intP=s.rfind ('/', pos-1); +S.erase (p,pos-p+3); - } the } * $ while((Pos=s.find ("/./"))!=-1){Panax NotoginsengS.erase (POS,2); - } the + if(S.size () >1&&s[s.size ()-1]=='/') AS.erase (S.size ()-1); the L.push_back (s); + } - for(intI=0; i<n;i++){ $cout<<l[i]<<Endl; $ } - return 0; -}
stl+ Analog CCF2016 4 Path resolution