A. BerOS file system
time limit per test

2 seconds

memory limit per test

64 megabytes

input

standard input

output

standard output

The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'.
For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are
equivalent. The character '/' (or some sequence of such characters) at the end of the path is required only in case of the path to the root directory, which
can be represented as single character '/'.

A path called normalized if it contains the smallest possible number of characters '/'.

Your task is to transform a given path to the normalized form.

Input

The first line of the input contains only lowercase Latin letters and character '/' — the path to some directory. All paths start with at least one character '/'.
The length of the given line is no more than 100 characters, it is not empty.

Output

The path in normalized form.

Examples
input
//usr///local//nginx/sbin
output
/usr/local/nginx/sbin
遇到多个////
只输出一个/
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h> using namespace std;
char a[105];
char b[105];
int main()
{
gets(a);
bool tag=0;
int len=strlen(a);
int cnt=0;
for(int i=0;i<len;i++)
{
if(a[i]!='/')
{
// cout<<a[i];
b[cnt++]=a[i];
tag=0;
} else
{
if(!tag)
{
//cout<<a[i];
b[cnt++]=a[i];
tag=1;
}
}
}
if(b[0]!='/')
cout<<'/';
for(int i=0;i<cnt;i++)
{
if(i==cnt-1&&b[i]=='/'&&cnt!=1)
continue;
cout<<b[i];
}
cout<<endl;
return 0;
}

Code Forces 20A BerOS file system的更多相关文章

  1. BerOS file system

    The new operating system BerOS has a nice feature. It is possible to use any number of characters '/ ...

  2. CDOJ_327 BerOS file system

    原题地址:http://acm.uestc.edu.cn/#/problem/show/327 The new operating system BerOS has a nice feature. I ...

  3. 题解 CF20A 【BerOS file system】

    对于此题,我的心近乎崩溃 这道题,注意点没有什么,相信大佬们是可以自己写出来的 我是蒟蒻,那我是怎么写出来的啊 好了,废话少说,开始进入正题 这道题,首先我想到的是字符串的 erase 函数,一边运行 ...

  4. Low-overhead enhancement of reliability of journaled file system using solid state storage and de-duplication

    A mechanism is provided in a data processing system for reliable asynchronous solid-state device bas ...

  5. Linux File System

    目录 . Linux文件系统简介 . 通用文件模型 . VFS相关数据结构 . 处理VFS对象 . 标准函数 1. Linux文件系统简介 Linux系统由数以万计的文件组成,其数据存储在硬盘或者其他 ...

  6. [CareerCup] 8.9 An In-memory File System 内存文件系统

    8.9 Explain the data structures and algorithms that you would use to design an in-memory file system ...

  7. TFS(Taobao File System)安装方法

    文章目录: 一.TFS(Taobao File System)安装方法 二.TFS(Taobao File System)配置dataServer.分区.挂载数据盘 三.TFS(Taobao File ...

  8. HTML5之本地文件系统API - File System API

    HTML5之本地文件系统API - File System API 新的HTML5标准给我们带来了大量的新特性和惊喜,例如,画图的画布Canvas,多媒体的audio和video等等.除了上面我们提到 ...

  9. File System Shell

    Overview appendToFile cat chgrp chmod chown copyFromLocal copyToLocal count cp du dus expunge get ge ...

随机推荐

  1. How To run OAI eNB (No S1) with USRP X310(1)

    How To run OAI eNB (No S1) with USRP X310 1.Things need to be done 1.1 Install Ubuntu 14.04 1.1.1 In ...

  2. HttpURLConnection上传文件

    HttpURLConnection上传文件 import java.io.BufferedReader; import java.io.DataInputStream; import java.io. ...

  3. 466. Count Linked List Nodes【Naive】

    Count how many nodes in a linked list. Example Given 1->3->5, return 3. 解法一: /** * Definition ...

  4. Selenium 之18 种定位方式

    1 id 定位 driver.find_element_by_id() HTML 规定id 属性在HTML 文档中必须是唯一的.这类似于公民的身份证号,具有很强的唯一性 from selenium i ...

  5. Python字符与ASCII码转换

    有两个内置函数,记得以前在<Python Cookbook>里看到过. >>>print ord('a') 97 >>>print chr(97) a

  6. python 加密方法总结

    MD5 def md5(str): import hashlib m = hashlib.md5() m.update(str) return m.hexdigest() base64 import ...

  7. js代码中定义后台java中的上下文路径

    var href = <c:out value='${sessionScope.contextPath}' />

  8. 匈牙利命名法、骆驼命名法、帕斯卡(pascal)命名法 C#命名规范

    匈牙利命名法.骆驼命名法.帕斯卡(pascal)命名法 C#命名规范 一.匈牙利命名法:广泛应用于象Microsoft Windows这样的环境中. Windows 编程中用到的变量(还包括宏)的命名 ...

  9. 卖座网一处SQL注射(Http Referer sqlinjection)

    漏洞作者: 猪猪侠 漏洞详情 披露状态: 2015-01-13: 细节已通知厂商并且等待厂商处理中2015-01-14: 厂商已经确认,细节仅向厂商公开2015-01-24: 细节向核心白帽子及相关领 ...

  10. Unix系统编程()虚拟内存管理

    在之前学到过进程的内存布局中忽略了一个事实:这一布局存在于虚拟文件中. 因为对虚拟内存的理解将有助于后续对fork系统调用.共享内存和映射文件之类的主题阐述,这里还要学习一下有关虚拟内存的详细内容. ...