include cstdio include iostream include string using namespace std int

 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
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main (void)
{string s, prot, hos, por, pat;
int i, n, x;
char c;
scanf ("%d\n", &n);
i=1;
while (i<=n)
{ pat=por="<default>";
while ((c=getchar())!=':')
prot=prot+c;
getchar(); getchar();
while (((c=getchar())!=':')&&(c!='/')&&(c!='\n'))
hos=hos+c;
if (c==':')
{
por.clear();
while (((c=getchar())!='/')&&(c!='\n'))
por=por+c;
}
if (c=='/')
{
pat.clear();
while ((c=getchar())!='\n')
pat=pat+c;
}
cout << "URL #" << i << endl;
cout << "Protocol = " << prot << endl;
cout << "Host = " << hos << endl;
cout << "Port = " << por << endl;
cout << "Path = " << pat << endl << endl;
i++;
}
return 0;
}