include cstdio include string using namespace std int main string host

 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
#include <cstdio>
#include <string>
using namespace std;
int main ()
{
string host,prot,sst, port, path;
char ch;
int n;
scanf("%d", &n);
for (int i=1;i<n+1;i++)
{
prot.clear();
ch=getchar();
while (ch!= ':')
{
ch=getchar();
prot+=ch;
}
printf("URL #%d\n", i);
printf("Protocol = %s\n",prot.c_str());
if (ch=='/')
{
do {ch=getchar(); host+=ch;}
while ((ch!=':')&&(ch!='/'));
printf("Host = %s\n", host.c_str());
}
if (ch==':')
{
while ((ch!='/')&&(ch!='\n'))
{
ch=getchar();
port+=ch;
}
printf("Port = %s", port.c_str());
}
else printf("Port = <default>\n");
if (ch='/')
{
while (ch!='\n')
{
ch=getchar();
path+=ch;
printf("Path = %s\n", path.c_str());
}
}
else printf("Path = <default>\n");
}
}