#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector> using namespace std;
int n;
const int maxn=1e3+;
char str[maxn];
string rel;
void handle(){
int len=strlen(str);
len--;
if(len==){
cout<<rel<<endl;
return;
}
string ans;
ans.clear();
if(str[]=='/'){
ans="";
}else{
ans=rel;
}
int i=;
while(i<len){
if(str[i]=='.'&&i+<len&&str[i+]=='.'&&((i+<len&&str[i+]=='/')||(i+==len))){
int j=ans.length()-;
for(;j>=;j--){
if(ans[j]=='/'){
break;
}
}
if(j<) ans="";
else ans=ans.substr(,j);
i+=;
}else if(str[i]=='.'&&((i+<len&&str[i+]=='/')||(i+==len))){
i++;
}else if(str[i]=='/'){
while(++i<len&&str[i]=='/');
}else{
string tmp="/";
tmp+=str[i];
while(++i<len&&str[i]!='/'){
tmp+=str[i];
}
ans+=tmp;
}
}
if(ans==""){
printf("/\n");
return;
}else{
cout<<ans<<endl;
return;
}
}
int main(){
cin>>n;
getchar();
fgets(str,maxn,stdin);
rel.clear();
for(int i=;i<strlen(str)-;i++){
rel+=str[i];
}
while(n--){
fgets(str,maxn,stdin);
handle();
}
return ;
}

【CCF】路径解析 模拟的更多相关文章

  1. CCF|路径解析|Java

    import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=ne ...

  2. stl+模拟 CCF2016 4 路径解析

    // stl+模拟 CCF2016 4 路径解析 // 一开始题意理解错了.... #include <iostream> #include <string> #include ...

  3. CCF CSP 201604-3 路径解析

    CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201604-3 路径解析 问题描述 在操作系统中,数据通常以文件的形式存储在文件系统中.文件系 ...

  4. requirejs:让人迷惑的路径解析

    接触过requirejs的童鞋可能都知道,无论是通过define来定义模块,还是通过require来加载模块,模块依赖声明都是很重要的一步.而其中涉及到的模块路径解析,对于新手来说,有的时候会让人觉得 ...

  5. 转:VC include 路径解析

    VC include 路径解析 要了解vc中使用#include命令包含头文件所搜寻的路径,必须先了解vc中的几种路径: 1. 系统路径 系统路径在vc中是"Tools->Option ...

  6. JSP Servlet 路径解析 路径设置

    转自:http://ethen.iteye.com/blog/800415 在用JSP和Servlet编写Web应用时,经常遇到的问题就是找不到.do路径,或者.do路径不能解析,其实归根到底就是Se ...

  7. 转:requirejs:让人迷惑的路径解析(~~不错)

    接触过requirejs的童鞋可能都知道,无论是通过define来定义模块,还是通过require来加载模块,模块依赖声明都是很重要的一步.而其中涉及到的模块路径解析,对于新手来说,有的时候会让人觉得 ...

  8. Xamarin版的C# SVG路径解析器

    原文:Xamarin版的C# SVG路径解析器 Xamarin版的C# SVG路径解析器,对SVG的Path路径进行解析,其中包括: 主程序SvgPathParser.cs, 相关接口定义:ISour ...

  9. nodejs系列笔记02---模块路径解析

    模块路径解析规则 参考这篇博客 我们已经知道,require函数支持斜杠(/)或盘符(C:)开头的绝对路径,也支持./开头的相对路径.但这两种路径在模块之间建立了强耦合关系,一旦某个模块文件的存放位置 ...

随机推荐

  1. React后台管理系统- rc-pagination分页组件封装

    1.用户列表页面使用的rc-pagination分页组件 Github地址: https://github.com/react-component/pagination 2.安装 cnpm insta ...

  2. Wordpress菜单函数wp_nav_menu各参数详解及示例

    Wordpress菜单函数wp_nav_menu各参数详解及示例   注册菜单 首先要注册菜单,将以下函数添加至function.php函数里   register_nav_menus(array( ...

  3. 两种简单的servlet实现反向代理

    以下两种方法都需要引入jar包: <dependency> <groupId>org.mitre.dsmiley.httpproxy</groupId> <a ...

  4. oc block排序

    NSArray *sortArr=[arr sortedArrayUsingSelector:@selector(compareWithClassAndName:)]; //数组排序--block N ...

  5. 第29题:LeetCode54:Spiral Matrix螺旋矩阵

    给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素. 示例 1: 输入: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ...

  6. Java - 类加载的时候,是有缺省同步锁的

    类加载的时候,是有缺省同步锁的

  7. (82)zabbix如何选择适合的监控类型

    zabbix提供十几种监控类型,包括:Zabbix agent, Simple checks, SNMP, Zabbix internal, IPMI, JMX monitoring等等,那我们应该如 ...

  8. 新装NGINX重启,出现错误 nginx: [error] open() "/usr/local/nginx/logs/nginx.pid"

    重装nginx出现,重启出现错误 ./nginx -s reload nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" ...

  9. vue2.0:子组件调用父组件

    main.js文件添加如下: new Vue({ router, render: h => h(App), data: { eventHub: new Vue() }}).$mount('#ap ...

  10. django开发基础

    一.配置静态文件 https://www.cnblogs.com/lshedward/p/10351051.html 二.路由分发 https://www.cnblogs.com/lshedward/ ...