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
****************************************************************/





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值