Code Forces 20A BerOS file system
2 seconds
64 megabytes
standard input
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.
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.
The path in normalized form.
//usr///local//nginx/sbin
/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的更多相关文章
- BerOS file system
The new operating system BerOS has a nice feature. It is possible to use any number of characters '/ ...
- CDOJ_327 BerOS file system
原题地址:http://acm.uestc.edu.cn/#/problem/show/327 The new operating system BerOS has a nice feature. I ...
- 题解 CF20A 【BerOS file system】
对于此题,我的心近乎崩溃 这道题,注意点没有什么,相信大佬们是可以自己写出来的 我是蒟蒻,那我是怎么写出来的啊 好了,废话少说,开始进入正题 这道题,首先我想到的是字符串的 erase 函数,一边运行 ...
- 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 ...
- Linux File System
目录 . Linux文件系统简介 . 通用文件模型 . VFS相关数据结构 . 处理VFS对象 . 标准函数 1. Linux文件系统简介 Linux系统由数以万计的文件组成,其数据存储在硬盘或者其他 ...
- [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 ...
- TFS(Taobao File System)安装方法
文章目录: 一.TFS(Taobao File System)安装方法 二.TFS(Taobao File System)配置dataServer.分区.挂载数据盘 三.TFS(Taobao File ...
- HTML5之本地文件系统API - File System API
HTML5之本地文件系统API - File System API 新的HTML5标准给我们带来了大量的新特性和惊喜,例如,画图的画布Canvas,多媒体的audio和video等等.除了上面我们提到 ...
- File System Shell
Overview appendToFile cat chgrp chmod chown copyFromLocal copyToLocal count cp du dus expunge get ge ...
随机推荐
- 【剑指Offer学习】【面试题22:栈的压入、弹出序列】
题目:输入两个整数序列,第一个序列表示栈的压入顺序,请推断二个序列是否为该栈的弹出顺序.假设压入栈的全部数字均不相等. 解题思路: 解决问题非常直观的想法就是建立一个辅助栈.把输入的第一个序列中的数字 ...
- 01、Windows Store APP 设置页面横竖屏的方法
在 windows phone store app 中,判断和设置页面横竖屏的方法,与 silverlight 中的 Page 类 不同,不能直接通过 Page.Orientation 进行设置.而是 ...
- prompt() 方法
定义和用法 prompt() 方法用于显示可提示用户进行输入的对话框. 语法 prompt(text,defaultText) 参数 描述 text 可选.要在对话框中显示的纯文本(而不是 HTML ...
- spring oauth2相关资料
理解OAuth 2.0 *****http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html Secure REST API with oauth2 ...
- spark源代码
电子书: https://spark-internals.books.yourtion.com/
- 路由搭建ovpn
教程一(外网搭建): 1. 注册花生壳帐号,同时系统会赠送一个免费的域名 2.登录华硕路由,找到花生壳代码设置花生壳登录名和密码.域名,删掉前面的"#"后,点击应用本页面设置,软重 ...
- poj2774(后缀数组水题)
http://poj.org/problem?id=2774 题意:给你两串字符,要你找出在这两串字符中都出现过的最长子串......... 思路:先用个分隔符将两个字符串连接起来,再用后缀数组求出h ...
- [TI-Sitara]启动流程
前段时间在准备AM437x启动相关的一些事情,对MLO.SPL等事情也是有些糊涂,于是分享下面这篇文章 转自:http://blog.csdn.net/psvoldemort/article/deta ...
- linux - camera capture
//cut a picture#include <stdio.h>#include <stdlib.h>#include <string.h>#include &l ...
- 基于Xilinx的Synthesize
所谓综合.就是讲HDL语言.原理图等设计输入翻译成由与.或.非们和RAM.触发器登记本逻辑单元的逻辑连接(即网表).并依据目标和要求(约束条件)优化生成的逻辑连接. ISE-XST XST是Xilin ...