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 ...
随机推荐
- LeetCode:搜索二维矩阵【74】
LeetCode:搜索二维矩阵[74] 题目描述 编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值.该矩阵具有如下特性: 每行中的整数从左到右按升序排列. 每行的第一个整数大于前一行的 ...
- php大转盘抽奖
抽奖大转盘演示:http://www.sucaihuo.com/php/3301.html function getRand($proArr, $proCount) { $result = ''; $ ...
- linux中搭建docker
1.通过 vagrant ssh登录虚拟机 2.在虚拟机中通过 yum 命令安装docker 3.通过docker -v检查docker是否安装成功 4.开启docker加速器 curl -sSL h ...
- Struts2笔记03——架构(转)
原始内容:https://www.tutorialspoint.com/struts_2/basic_mvc_architecture.htm 架构(很重要!尤其是图!) 从一个比较高的层次来看,St ...
- Linux网络检测手段汇总
1.iftop iftop可测量通过每一个套接字连接传输的数据:它采用的工作方式有别于nload.iftop使用pcap库来捕获进出网络适配器的数据包,然后汇总数据包大小和数量,搞清楚总的带宽使用情况 ...
- js 工厂模式简要介绍
什么是工厂模式?就好比一个工厂,能造汽车.飞机...,通过对外接口,由顾客决定,来定制哪一款产品. 在js内表现为,一个工厂函数/对象,包含汽车.飞机等子类,提供对外接口,根据参数返回不同子类的实例 ...
- [算法]在单链表和双链表中删除倒数第k个结点
题目: 分别实现两个函数,一个可以删除单链表中倒数第K个节点,另一个可以删除双链表中倒数第K个节点. 要求: 如果链表长度为N,时间复杂度达到O(N),额外空间复杂度达到O(1). 解答: 让链表从头 ...
- python脚本发送电子邮件
#!/usr/bin/pythonimport smtplibimport stringHOST='smtp.qq.com'#HOST='mail.qq.com'SUBJECT='Test email ...
- Lucene简单介绍
[2016.6.11]以前写的笔记,拿出来放到博客里面~ 相关软件: Solr, IK Analyzer, Luke, Nutch;Tomcat; 1.是什么: Lucene是apache软件基金会j ...
- bat定时检测系统服务是否开启
@echo offrem 定义循环间隔时间和监测的服务:set secs=90set srvname="Apache2a" echo.echo ================== ...