2014
03-03

# Slash

The American English slash (/) is a punctuation mark. In the early modern period, in the Fraktur script, which was widespread through Europe in the Middle Ages, one slash(/) represented a comma, while two slashes (//) represented a dash.
With the wide use of computers, slash appeared far more than at any previous time in history. On Unix-like systems and in URLs, the slash is to separate directory and file components of a path:
/home/whuacm/chaeyeon/Sherlockpp.jpg
http://acm.whu.edu.cn/
But in Windows systems, it uses (\) to separate directory and file components of a path:
C:\Users\v-yungao\Music\Shake
That really confuses me. Could you help me to judge if the string I wrote is right.
Please notice that I would only make a mistake by changing (\) to (/) or (/) to (\). All the strings were constituted by a-z, A-Z, 0-9, (.) , (\) and (/), no other characters would appear in the strings.
A string of URL always begins with “[a-zA-Z]+://” (Notice (/) maybe changed to (\) ), in which “[a-zA-Z]+” represents any non-empty string of letters.
Windows path begins with “[a-zA-Z]:\” (Notice (\) maybe changed to (/)), in which “[a-zA-Z]” means an English letter. (e.g. “C:\\windows” is a URL not a Windows path)
The path of Unix-like system begins with (/) or (\).
I’ll give you some strings, can you tell me which type those strings belong to and those correct forms.

The first line consists of an integer T, indicating the number of strings.
The next T lines, each line consists of a single non-empty string. All of those are really data from our daily life.

The first line consists of an integer T, indicating the number of strings.
The next T lines, each line consists of a single non-empty string. All of those are really data from our daily life.

4

http://acm.whu.edu.cn/felioj

http:/\acm.whu.edu.cn/11111011001/
\home\whuacm\Slash\yama
Z:\movie/chaeyeon

It's a URL!

http://acm.whu.edu.cn/felioj

It's a URL!

http://acm.whu.edu.cn/11111011001/

It's a path in Unix-like systems!
/home/whuacm/Slash/yama
It's a path in Windows system!
Z:\movie\chaeyeon

#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;

int main(){
//freopen("1.txt","r",stdin);
int T;
scanf("%d",&T);
while(T--){
char ss[60];
scanf("%s",ss);
int flag = 0;
if(ss[0] == '\\' || ss[0] == '/'){
printf("It's a path in Unix-like systems!\n");
for(int i = 0; i < strlen(ss); ++i){
if(ss[i] == '\\')
printf("/");
else
printf("%c",ss[i]);
}
printf("\n");
}
else{
flag = 0;
for(int i = 0; i < strlen(ss) - 1; ++i){
if((ss[i] == '\\' || ss[i] == '/') && (ss[i+1] == '\\' || ss[i + 1] == '/')){
// printf("i = %d\n",i);
flag = 1;
break;
}
}
if(flag == 1){
printf("It's a URL!\n");
for(int i = 0; i < strlen(ss); ++i){
if(ss[i] == '\\')
printf("/");
else
printf("%c",ss[i]);
}
printf("\n");
}
else{
printf("It's a path in Windows system!\n");
for(int i = 0; i < strlen(ss); ++i){
if(ss[i] == '/')
printf("\\");
else
printf("%c",ss[i]);
}
printf("\n");
}
}
}
return 0;
}

1. 其实国内大部分公司对算法都不够重视。特别是中小型公司老板根本都不懂技术，也不懂什么是算法，从而也不要求程序员懂什么算法，做程序从来不考虑性能问题，只要页面能显示出来就是好程序，这是国内的现状，很无奈。