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
#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=getchar())!= ':')
{
prot+=ch;
}
printf("URL #%d\n", i);
printf("Protocol = %s\n",prot.c_str());
getchar();
getchar();
while ((ch=getchar())!=':' && ch !='/') host += ch;
printf("Host = %s\n", host.c_str());
if (ch==':')
{
while ((ch=getchar()!='/')&&(ch!='\n'))
port+=ch;
printf("Port = %s\n", port.c_str());
}
else printf("Port = <default>\n");
getchar();
if (ch='\n') printf("Path = <default>\n");
else
{
while ((ch=getchar())!='\n')
path+=ch;
printf("Path = %s\n", path.c_str());
}
}
}