ccf字符串题
来源:互联网 发布:javascript设计模式pdf 编辑:程序博客网 时间:2024/06/05 18:11
#include <iostream>#include <string>#include <vector>using namespace std;int main(){ int num; string curDir; vector<string> list; cin>>num>>curDir; cin.ignore(); for(int i=0; i<num; i++){ string line; getline(cin,line); if(line == ""){ list.push_back(curDir); continue; } int pos; // 除去多个/// while( (pos=line.find("//"))!=-1 ){ int count = 2; while(line[pos+count]=='/'){ count++; } line.erase(pos,count-1); } // 除去../ while( (pos=line.find("../"))!=-1 ){ if(line[0]=='/'){ if(pos==1){ line.erase(pos,3); }else{ int spos; spos = line.rfind("/",pos-2);//相当于倒着找上一个/,然后整体删除 line.erase(spos,pos-spos+2); } }else{ line = curDir+"/"+line; } //cout <<" line = " << line << endl; } // 除去./ while( (pos=line.find("./"))!=-1 ){ line.erase(pos,2); } if(line.size()>1 && line[line.size()-1]=='/') line.erase(line.size()-1); list.push_back(line); } for(int j=0; j<num; j++){ cout<<list[j]<<endl; } return 0;}
0 0
- ccf字符串题
- ccf题目:字符串匹配
- CCF 字符串匹配
- 【CCF】字符串匹配
- CCF试题:字符串匹配
- ccf 字符串匹配
- ccf 字符串匹配
- ccf 字符串匹配
- CCF 字符串匹配
- CCF 字符串匹配
- CCF字符串匹配
- ccf试题 字符串匹配
- ccf认证字符串匹配
- CCF-训练50题-NO.6-字符串匹配问题
- CCF-训练50题-NO.16-字符串数字置换
- 字符串匹配-CCF测试往届题
- CCF 字符串匹配201409-3
- CCF 201409-3 字符串匹配
- [SCU 4437 Carries] 二分
- 各种实用的模板和黑科技(缓更)
- 14All configured PGW endpoint service URIs are unusable.
- 数据结构实验之图论六:村村通公路
- IOS-corelocation
- ccf字符串题
- js操作cookie
- 【BZOJ3555】企鹅QQ,第一次正确的使用哈希A题
- 数组排序 —— 常见排序练习题(有序矩阵查找、最短子数组)
- 【bzoj 4547】【Hdu 5171】小奇的集合(找规律+矩阵快速幂)
- 51nod 1491 黄金系统
- FOJ有奖月赛-2016年8月 Problem A Daxia & Wzc's problem(找规律)
- 8-17比赛总结
- HDU 5855 Less Time, More profit(最大权闭合子图)