include iostream include cstdio using namespace std int main string ur

 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
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
string url, protocol, host, port="<default>", path="<default>";
int count;
scanf("%d\n",&count);
int total=count;
while(count--)
{
char c;
while ((c=getchar())!=':')
protocol += c;
getchar(); getchar();
while ((c=getchar())!=':' && c!='/' && c!='\n')
host +=c;
if (c!='\n')
{
if (c==':')
{
port.clear();
while ((c=getchar())!='/' && c!='\n')
port += c;
}
if (c!='\n')
{
path.clear();
while((c=getchar())!='\n')
path+=c;
}
}
cout << "URL #" << total-count << endl;
cout << "Protocol = " << protocol << endl;
cout << "Host = " << host << endl;
cout << "Port = " << port << endl;
cout << "Path = " << path << endl << endl;
protocol.clear();
host.clear();
port="<default>";
path="<default>";
}
}