#include using namespace std; void showstack(stack s) { while (!s.empty()) { cout << '\t' << s.top(); s.pop(); } } void del(stack &a){ if(a.size() == 0) return; while(a.top() != '/'){ a.pop(); } a.pop(); } int main(){ ios::sync_with_stdio(0); cin.tie(0); string s; stack a; int n,i,j,key; cin>>n; while(n>0){ cin>>s; i=0; char cm[5]; while(s[i]!=' ' && s[i]!='\0'){//cp phan command cm[i]=s[i]; i+=1; } cm[i]='\0'; if(strcmp(cm,"pwd") == 0) {//kiem tra lenh showstack(a); cout<<'/'; cout<<'\n'; } else{ j=i+1; while(s[j] != '\0'){ if(s[j] == '.') { del(a); j+=2;//nhay den vi tri dia chi continue; } a.push(s[j]); j+=1; } } n-=1; } }