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 ...
随机推荐
- [Jobdu] 题目1348:数组中的逆序对
题目描述: 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对.输入一个数组,求出这个数组中的逆序对的总数. 输入: 每个测试案例包括两行: 第一行包含一个整数n,表示数组 ...
- 线程相关函数(4)-pthread_mutex_lock(), pthread_mutex_unlock() 互斥锁
互斥锁实例: #include <pthread.h>pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;int pthread_mutex ...
- 每日英语:A Better Way To Treat Anxiety
Getting up the nerve to order in a coffee shop used to be difficult for 16-year-old Georgiann Steely ...
- 把一张图片 转成二进制流 用AFNetworking POST 上传到服务器.
把一张图片 转成二进制流 用AFNetworking POST 上传到服务器. AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOper ...
- 开源搜索引擎评估:lucene sphinx elasticsearch (zhuan)
http://lutaf.com/158.htm ************************ 开源搜索引擎程序有3大类 lucene系,java开发,包括solr和elasticsearch s ...
- django 使用post方法出现403错误的解决办法
当采用客户端象django的服务器提交post请求时.会得到403,权限异常.因为django针对提交的请教,有校验.所以会如此. 解决办法: 导入模块:from django.views.decor ...
- 原创jQuery插件之图片自适应
效果图例如以下: 功能:使图片自适应居中位于容器内 限制:容器须要给定大小 用法: 1.引入jQuery.然后引入fitimg插件 2.给须要图片自适应的容器固定宽高 3.header .accoun ...
- [Linux]gcc/libc/glibc
转自:http://blog.csdn.net/weiwangchao_/article/details/16989713 1.gcc(gnu collect compiler)是一组编译工具的总称. ...
- vmware无法打开内核设备“\\.\Global\vmx86”: 系统找不到指定的文件
原因: 是虚拟机服务没有开启 解决方法:(以管理员的方式运行) 点击“开始→运行”,在运行框中输入 CMD 回车打开命令提示符,然后依次执行以下命令. net start vmcinet start ...
- datagrid.celltips.js
/** * Created with JetBrains WebStorm. * User: cao.guanghui * Date: 13-6-26 * Time: 下午11:27 * To cha ...