1077: Slash

1077: Slash
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 3 Solved: 2
[Submit][Status][Web Board]
Description

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.
Input
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.
Output
For each string:
If it belongs to a path in Unix-like systems, output “It’s a path in Unix-like systems!” in a new line and the correct string in the next line.
If it belongs to a path in Windows system, output “It’s a path in Windows system!” in a new line and the correct string in the next line.
If it’s a URL, output “It’s a URL!” in a new line and the correct string in the next line.
The kind of each input string can be uniquely determined.

Constrains
0 < T <= 20
The length of each string will not be longer than 50.
Sample Input

4

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

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

/\home\whuacm\Slash\yamaZ:\movie/chaeyeon

Sample Output

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 syste

请欲参加ACM大赛的同学练习问题集中的题目

?


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

#include <iostream>

#include <string>

using
namespace
std;

 

int
main()

{

    int
testNum;

    string str;

    char
ch;

 

    cin >> testNum;

    cin.get();

    for
(int
test = 1; test <= testNum; test++)

    {

        cin >> str;

        if
(str[0] == '/'
||  str[0] ==
'\\')

        {//UINX

            for
(int
i = 0; i < str.size(); i++)

            {

                if
(str[i] == '\\')

                    str[i] =
'/';

            }

            cout <<
"It's a path in Unix-like systems!"
<< endl;

        }

        else

        {

            int
i;

            for
(i = 0; i < str.size(); i++)

            {

                if
(str[i] == ':')

                    break;

            }

            //URL

            if
(str[i+2] == '\\'
|| str[i+2] ==
'/')

            {

                cout <<
"It's a URL!" << endl;

                for
(i = 0; i < str.size(); i++)

                {

                    if
(str[i] == '\\')

                        str[i] =
'/';

                }

            }//windows

            else

            {   
for (i = 0; i < str.size(); i++)

                {

                    if
(str[i] == '/')

                        str[i] =
'\\';

                }

                cout <<
"It's a path in Windows system!"
<< endl;

            }

 

        }

 

        cout << str << endl;

    }

 

    return
0;

}

 

/**************************************************************

    Problem: 1077

    User: 1006440533

    Language: C++

    Result: Accepted

    Time:0 ms

    Memory:1272 kb

****************************************************************/

时间: 2024-12-22 15:50:53

1077: Slash的相关文章

POJ 1077 Eight:八数码问题

题目链接: http://poj.org/problem?id=1077 题目类型: 隐式图搜索 原题: The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all pac

Slash称赞枪花重聚坚决不跟罗斯和好(图)

麦卡甘在伦敦O2和罗斯同台 新浪娱乐讯 北京时间11月5日消息,据国外媒体报道,上个月当枪花乐队在伦敦O2体育馆演出时,前任贝斯手达夫·麦克甘突然出现,和主唱埃克赛尔·罗斯在阔别13年后首度同台.前任吉他手Slash连声称赞这次老友重聚,自己却没有打算和罗斯握手言和. 尽管现在的枪花成员众多,在人们心中却只是"埃克赛尔·罗斯和他的乐队":无论Slash.达夫·麦卡甘.马特·索勒姆走到哪里,他们永远都是"前枪花成员".由主唱罗斯.吉他手Slash.贝斯手麦卡甘和鼓手索

Crontab中的除号(slash)到底怎么用?

crontab 是Linux中配置定时任务的工具,在各种配置中,我们经常会看到除号(Slash)的使用,那么这个除号到底标示什么意思,使用中有哪些需要注意的地方呢?   在定时任务中,我们经常有这样的需求,比如每5分钟查看一下日志,我们可以这么写:   0,5,10,15,20,25,30,35,40,45,50,55 * * * * /command   这样肯定是没有问题的,但是就写书写起来非常复杂,简化一下可以这么写:   0-55/5 * * * * /command   这样的写法已经

国家知识产权局:去年受理专利侵权案1077件

摘要: 国家知识产权局局长田力普21日在国新办新闻发布会上说,2010年,全国知识产权局系统共受理专利侵权纠纷案件1077件,查处假冒专利案件728件. 新华网快讯:国家知识产权局局长田力普21日在国新办新闻发布会上说,2010年,全国知识产权局系统共受理专利侵权纠纷案件1077件,查处假冒专利案件728件.

hdu 1077 Catching Fish 计算几何+暴力枚举

   简单的暴力枚举,枚举两个点在圆上,用向量法求下圆心.复杂度o(n^3),但数据量只有300 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <iostream> #include <cstdio> #include <cstdlib> #include <c

UVa 705:Slash Maze, 斜线迷宫

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=105&page=show_problem&problem=646 题目类型: 搜索 题目: By filling a rectangle with slashes (/) and backslashes ( ), you can generate nice little mazes. Here is an

uva 652---Eight Poj 1077 ---Eight zoj 1217---Eight (八数码解法2)

点击打开链接uva 652 点击打开链接hdu 1043 点击打开链接zoj 1217                                                              八数码解法2 解题整体思路 :    预处理+哈希判重+打表+输出路径                               我们知道对于八数码问题而言,每一个状态就是每一个格子的编号(我们把空格看成9),那么最多有9!种,那么现在针对每一种状态都有9个数字,难道我们开一个9维数组,

uva 652---Eight Poj 1077 ---Eight zoj 1217---Eight (八数码解法3)

点击打开链接uva 652 点击打开链接hdu 1043 点击打开链接zoj 1217                                                              八数码解法3 解题整体思路 :    双向广搜+哈希判重+输出路径                      (目前只能AC poj 数据水了不解释,其它的OJ一直TLE,求教)                               我们知道对于八数码问题而言,每一个状态就是每一个格

uva 652---Eight Poj 1077 ---Eight zoj 1217---Eight (八数码解法1)

点击打开链接uva 652 点击打开链接hdu 1043 点击打开链接zoj 1217                                                              八数码解法1 解题整体思路 :    单向广搜+哈希判重+输出路径(这种方法效率不高,目前小弟的程序只能过POJ 其它TLE)                               我们知道对于八数码问题而言,每一个状态就是每一个格子的编号(我们把空格看成9),那么最多有9!种,那么