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 ...
随机推荐
- 关于.net 2.0 remoting 中 TCP Channel 用户认证探讨(一)
http://www.cnblogs.com/scucj/archive/2007/05/09/740808.html
- Struts2使用OGNL遍历各种map总结
一.Action中的代码:MapAction.java package com.zx.demo.action; import java.util.ArrayList; import java.ut ...
- Linux系统(Ubuntu/Debian/RedHat/CentOS)超级简单的samba配置文件smb.conf
1.超简单的smb.conf 该配置文件对Ubuntu和CentOS都好用. #============== Global Settings ============== [global] ## Br ...
- 在sql中根据成绩显示学生排名
1.准备 create table newtable ( name ), yuwen ), shuxue ) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; , ); , ...
- php的json校验json-schema
客户端和服务端的http信息传递,采用json几乎成了标配.json格式简单,易于处理,不过由于没有格式规定,无法校验. 好在php有json-schema模块,可以用来验证json是否符合规定的格式 ...
- 知乎日报 API 分析
声明 下面全部 API 均由 知乎(Zhihu.Inc) 提供,本人採取非正常手段获取. 获取与共享之行为或有侵犯知乎权益的嫌疑.若被告知需停止共享与使用.本人会及时删除此页面与整个项目. 请您暸解相 ...
- 原生sqlServer数据库连接
package tj.test.demo; import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Sta ...
- 下列JSP代码:
下列JSP代码: <html> <body> <% for(int i = 0; i < 10; i++) { //1 } %> </body> ...
- java为安全起见对Applet有所限制
Applet消亡的原因: ①java为安全起见对Applet有所限制:Applet不允许访问本地文件信息.敏感信息,不能执行本地指令(比如FORMAT),不能访问初原服务器之外的其他服务器. ① IE ...
- 嵌入式驱动开发之uboot---uboot 中的常见命令参数参数
Uboot相关命令介绍 bootm bootp cmp cp crc32 echo erase flinfo go minfo loadb loads mw 14mw 用指定的数据填充内存 15md ...