BerOS file system
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.
Example
//usr///local//nginx/sbin
/usr/local/nginx/sbin 读懂题意就好,英语不好。
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath> using namespace std; int main()
{
char s[];
char t[];
scanf("%s",s);
int i = ,j = ,c = ;
while(s[i])
{
t[j ++] = s[i];
if(s[i] == '/')
{
c ++;
while(s[i + ] == '/')i ++;
}
i ++;
}
if(c > )while(t[j - ] == '/')j --;
t[j] = '\0';
printf("%s",t);
}
BerOS file system的更多相关文章
- Code Forces 20A BerOS file system
A. BerOS file system time limit per test 2 seconds memory limit per test 64 megabytes input standard ...
- 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 函数,一边运行 ...
- BerOS File Suggestion(字符串匹配map)
BerOS File Suggestion(stl-map应用) Polycarp is working on a new operating system called BerOS. He asks ...
- Design and Implementation of the Sun Network File System
Introduction The network file system(NFS) is a client/service application that provides shared file ...
- 乌版图 read-only file system
今天在启动虚拟机的时候,运行命令svn up的时候,提示lock,并且read-only file system,这个....我是小白啊,怎么办?前辈在专心写代码,不好打扰,果断找度娘啊 于是乎,折腾 ...
- File system needs to be upgraded. You have version null and I want version 7
安装hbase时候报错: File system needs to be upgraded. You have version null and I want version 7 注: 我安装的hba ...
- Linux系统启动错误 contains a file system with errors, check forced解决方法
/dev/sda1 contains a file system with errors, check forced./dev/sda1: Inodes that were part of a cor ...
- Linux 执行partprobe命令时遇到Unable to open /dev/sr0 read-write (Read-only file system)
在使用fdisk创建分区时,我们会使用partprobe命令可以使kernel重新读取分区信息,从而避免重启系统,但是有时候会遇到下面错误信息"Warning: Unable to open ...
随机推荐
- 深入浅出Node.js(上)
(一):什么是Node.js Node.js从2009年诞生至今,已经发展了两年有余,其成长的速度有目共睹.从在github的访问量超过Rails,到去年底Node.jsS创始人Ryan Dalh加盟 ...
- Linux的XServer
Moblin Core是在Gnome Mobile的平台上建立.我以前玩Linux,提交的都和图像没有关系,连Xwindows都不用启动,开机后直接进入文本命令行,所以这方面了解得很少,需要学习一下, ...
- STM32系列第15篇--灵活的静态存储控制器FSMC
源: STM32系列第15篇--灵活的静态存储控制器FSMC
- github使用——如何恢复被删去文件。
首先git删除文件包括以下几种情况 删除本地文件,但是未添加到暂存区: 删除本地文件,并且把删除操作添加到了暂存区: 把暂存区的操作提交到了本地git库: 把本地git库的删除记录推送到了远程服务器g ...
- Django框架之cookie和session及开发登录功能
1.cookie是什么? Web应用程序是使用HTTP协议传输数据的.HTTP协议是无状态的协议.一旦数据交换完毕,客户端与服务器端的连接就会关闭,再次交换数据需要建立新的连接.这就意味着服务器无法从 ...
- 防止iframe被别的网站引用
try{ top.location.hostname; if (top.location.hostname != window.location.hostname) { top.location.hr ...
- https网站无法加载http路径的js和css
在https的网站中引用http路径的js或css会导致不起作用,其形如: <script src="http://code.jquery.com/jquery-1.11.0.min. ...
- 线性代数:A转置乘以A可逆
如果A的列向量线性无关,则 T(A)*A得到一个可逆的方阵. 假设A是一个kxn的矩阵,那么T(A)*A是一个nxn的方阵:要证明这个方阵可逆,只要证明N(T(A)*A) = 零空间即可. 假设列向量 ...
- linux运维面试题1
一.填空题 1. 在Linux 系统 中,以文件方式访问设备 . 2. Linux 内核引导时,从文件/etc/fstab中读取要加载的文件系统 . 3. Linux 文件系统中每个文件用indoe节 ...
- SEM竞价数据基本分析方法
今天我们从账户数据表现来看一看怎样通过数据分析,判断账户出现的问题及解决思路.也欢迎大家提出意见,共同讨论进步. 首先我们从关键词报告来分析数据: 以上图数据为例.(设定该行业CPC均价为8) 先说下 ...